@@ -370,7 +370,7 @@ function create_transition(dom, init, direction, effect) {
370
370
// out
371
371
o ( ) {
372
372
// @ts -ignore
373
- const has_keyed_transition = dom . __animate === true ;
373
+ const has_keyed_transition = dom . __animate ;
374
374
const needs_reverse = direction === 'both' && curr_direction !== 'out' ;
375
375
curr_direction = 'out' ;
376
376
if ( animation === null || cancelled ) {
@@ -402,11 +402,17 @@ function create_transition(dom, init, direction, effect) {
402
402
dom . style . height = height ;
403
403
const b = dom . getBoundingClientRect ( ) ;
404
404
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.
405
409
const style = getComputedStyle ( dom ) ;
406
410
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 ( ) ;
410
416
}
411
417
}
412
418
}
0 commit comments