@@ -370,7 +370,7 @@ function create_transition(dom, init, direction, effect) {
370370 // out
371371 o ( ) {
372372 // @ts -ignore
373- const has_keyed_transition = dom . __animate === true ;
373+ const has_keyed_transition = dom . __animate ;
374374 const needs_reverse = direction === 'both' && curr_direction !== 'out' ;
375375 curr_direction = 'out' ;
376376 if ( animation === null || cancelled ) {
@@ -402,11 +402,17 @@ function create_transition(dom, init, direction, effect) {
402402 dom . style . height = height ;
403403 const b = dom . getBoundingClientRect ( ) ;
404404 if ( a . left !== b . left || a . top !== b . top ) {
405+ // Previously, in the Svelte 4, we'd just apply the transform the the DOM element. However,
406+ // because we're now using Web Animations, we can't do that as it won't work properly if the
407+ // animation is also making use of the same transformations. So instead, we apply an instantaneous
408+ // animation and pause it on the first frame, just applying the same behavior.
405409 const style = getComputedStyle ( dom ) ;
406410 const transform = style . transform === 'none' ? '' : style . transform ;
407- dom . style . transform = `${ transform } translate(${ a . left - b . left } px, ${
408- a . top - b . top
409- } px)`;
411+ const frame = {
412+ transform : `${ transform } translate(${ a . left - b . left } px, ${ a . top - b . top } px)`
413+ } ;
414+ const animation = dom . animate ( [ frame , frame ] , { duration : 1 } ) ;
415+ animation . pause ( ) ;
410416 }
411417 }
412418 }
0 commit comments