From 88d1287c545f32d14a342614ffa255e610b2988e Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 21 Mar 2024 18:34:08 -0400 Subject: [PATCH] remove animation before measuring --- .../svelte/src/internal/client/dom/elements/transitions.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; }); }