File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @vtbag/inspection-chamber ' : patch
3+ ---
4+
5+ Fixes an issue, where changing visibility of pseudo-elements did not work for cross-document view transitions.
Original file line number Diff line number Diff line change @@ -56,12 +56,15 @@ function initSpecimen() {
5656 const rewrite = ( cb ?: ViewTransitionUpdateCallback ) => async ( ) => {
5757 await Promise . resolve ( ) ;
5858 cb && ( await cb ( ) ) ;
59+ top ! . __vtbag . inspectionChamber ! . crossDocument = false ;
5960 pageReveal ( ) ;
6061 } ;
6162
6263 if ( CSS . supports ( 'selector(:active-view-transition-type(x))' ) ) {
6364 // level 2 signature
64- frameDocument . startViewTransition = ( obj ?: ViewTransitionUpdateCallback | StartViewTransitionOptions ) => {
65+ frameDocument . startViewTransition = (
66+ obj ?: ViewTransitionUpdateCallback | StartViewTransitionOptions
67+ ) => {
6568 const param : StartViewTransitionOptions = { types : undefined , update : undefined } ;
6669 ( '@vtbag' ) ;
6770 pageSwap ( ) ;
@@ -99,6 +102,7 @@ function pageSwap() {
99102function prePageReveal ( e : Event ) {
100103 inspectionChamber . viewTransition =
101104 ( 'viewTransition' in e && ( e . viewTransition as ViewTransition ) ) || undefined ;
105+ top ! . __vtbag . inspectionChamber ! . crossDocument = true ;
102106 pageReveal ( ) ;
103107}
104108function pageReveal ( ) {
Original file line number Diff line number Diff line change @@ -11,6 +11,21 @@ export function setStyles(
1111 prepend ? 'afterbegin' : 'beforeend' ,
1212 `<style id="${ id } ">${ styles } </style>`
1313 ) ;
14+
15+ if ( top ! . __vtbag . inspectionChamber ! . crossDocument ) {
16+ const animations = doc . getAnimations ( ) ;
17+ const pivot = animations . find (
18+ ( a ) => a . playState === 'paused' && a . effect ?. pseudoElement ?. startsWith ( '::view-transition' )
19+ ) ;
20+ if ( pivot )
21+ animations . forEach ( ( a ) => {
22+ const now = a . currentTime ;
23+ a . currentTime === 0 ? a . currentTime ++ : ( a . currentTime as number ) -- ;
24+ requestAnimationFrame ( ( ) => {
25+ a . currentTime = now ;
26+ } ) ;
27+ } ) ;
28+ }
1429}
1530
1631export function addFrames ( show : boolean , namedOnly : boolean ) {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export type InspectionChamber = {
1212 mainPanel ?: HTMLDivElement ;
1313 innerPanel ?: HTMLDivElement ;
1414 pushBack ?: HTMLDivElement | null ;
15+ crossDocument ?: boolean ;
1516} ;
1617
1718declare global {
You can’t perform that action at this time.
0 commit comments