diff --git a/packages/svelte/src/internal/client/dom/elements/transitions.js b/packages/svelte/src/internal/client/dom/elements/transitions.js index f3948073b0..387089f262 100644 --- a/packages/svelte/src/internal/client/dom/elements/transitions.js +++ b/packages/svelte/src/internal/client/dom/elements/transitions.js @@ -94,12 +94,12 @@ export function animation(element, get_fn, get_params) { from = this.element.getBoundingClientRect(); }, apply() { + animation?.abort(); + to = this.element.getBoundingClientRect(); const options = get_fn()(this.element, { from, to }, get_params?.()); - animation?.abort(); - if ( from.left !== to.left || from.right !== to.right || @@ -107,6 +107,7 @@ export function animation(element, get_fn, get_params) { from.bottom !== to.bottom ) { animation = animate(this.element, options, undefined, 1, () => { + animation?.abort(); animation = undefined; }); }