@@ -1550,16 +1550,20 @@ export function hasInstanceAffectedParent(
1550
1550
return oldRect . height !== newRect . height || oldRect . width !== newRect . width ;
1551
1551
}
1552
1552
1553
- function cancelAllViewTransitionAnimations ( ownerDocument : Document ) {
1553
+ function cancelAllViewTransitionAnimations ( scope : Element ) {
1554
1554
// In Safari, we need to manually cancel all manually start animations
1555
1555
// or it'll block or interfer with future transitions.
1556
- const animations = ownerDocument . getAnimations ( ) ;
1556
+ const animations = scope . getAnimations ( { subtree : true } ) ;
1557
1557
for ( let i = 0 ; i < animations . length ; i ++ ) {
1558
1558
const anim = animations [ i ] ;
1559
1559
const effect : KeyframeEffect = ( anim . effect : any ) ;
1560
1560
// $FlowFixMe
1561
1561
const pseudo : ?string = effect . pseudoElement ;
1562
- if ( pseudo != null && pseudo . startsWith ( '::view-transition' ) ) {
1562
+ if (
1563
+ pseudo != null &&
1564
+ pseudo . startsWith ( '::view-transition' ) &&
1565
+ effect . target === scope
1566
+ ) {
1563
1567
anim . cancel ( ) ;
1564
1568
}
1565
1569
}
@@ -1655,7 +1659,7 @@ export function startViewTransition(
1655
1659
}
1656
1660
transition . ready . then ( spawnedWorkCallback , spawnedWorkCallback ) ;
1657
1661
transition . finished . then ( ( ) => {
1658
- cancelAllViewTransitionAnimations ( ownerDocument ) ;
1662
+ cancelAllViewTransitionAnimations ( ( ownerDocument . documentElement : any ) ) ;
1659
1663
// $FlowFixMe[prop-missing]
1660
1664
if ( ownerDocument . __reactViewTransition === transition ) {
1661
1665
// $FlowFixMe[prop-missing]
@@ -1841,7 +1845,8 @@ export function startGestureTransition(
1841
1845
const pseudoElement : ?string = effect . pseudoElement ;
1842
1846
if (
1843
1847
pseudoElement != null &&
1844
- pseudoElement . startsWith ( '::view-transition' )
1848
+ pseudoElement . startsWith ( '::view-transition' ) &&
1849
+ effect . target === documentElement
1845
1850
) {
1846
1851
// Ideally we could mutate the existing animation but unfortunately
1847
1852
// the mutable APIs seem less tested and therefore are lacking or buggy.
@@ -1932,7 +1937,7 @@ export function startGestureTransition(
1932
1937
: readyCallback ;
1933
1938
transition . ready . then ( readyForAnimations , readyCallback ) ;
1934
1939
transition . finished . then ( ( ) => {
1935
- cancelAllViewTransitionAnimations ( ownerDocument ) ;
1940
+ cancelAllViewTransitionAnimations ( ( ownerDocument . documentElement : any ) ) ;
1936
1941
// $FlowFixMe[prop-missing]
1937
1942
if ( ownerDocument . __reactViewTransition === transition ) {
1938
1943
// $FlowFixMe[prop-missing]
0 commit comments