@@ -12,6 +12,7 @@ import clsx from 'clsx';
1212import type { CSSProperties , MouseEvent } from 'react' ;
1313import { forwardRef , useCallback , useEffect , useState } from 'react' ;
1414
15+ import { startScopedViewTransition } from '../../utils' ;
1516import type { IconButtonProps } from '../button' ;
1617import { IconButton } from '../button' ;
1718import * as styles from './styles.css' ;
@@ -86,21 +87,19 @@ class ModalTransitionContainer extends HTMLElement {
8687 }
8788
8889 this . animationFrame = requestAnimationFrame ( ( ) => {
89- if ( typeof document . startViewTransition === 'function' ) {
90- const nodes = this . pendingTransitionNodes ;
90+ const nodes = this . pendingTransitionNodes ;
91+ nodes . forEach ( child => {
92+ if ( child instanceof HTMLElement ) {
93+ child . classList . add ( 'vt-active' ) ;
94+ }
95+ } ) ;
96+ startScopedViewTransition ( styles . modalVTScope , ( ) => {
9197 nodes . forEach ( child => {
92- if ( child instanceof HTMLElement ) {
93- child . classList . add ( 'vt-active' ) ;
94- }
95- } ) ;
96- document . startViewTransition ( ( ) => {
97- nodes . forEach ( child => {
98- // eslint-disable-next-line unicorn/prefer-dom-node-remove
99- super . removeChild ( child ) ;
100- } ) ;
98+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
99+ super . removeChild ( child ) ;
101100 } ) ;
102- this . pendingTransitionNodes = [ ] ;
103- }
101+ } ) ;
102+ this . pendingTransitionNodes = [ ] ;
104103 } ) ;
105104 }
106105}
0 commit comments