From adfd6f0164c4d07353a8a79c78b1907791d9b211 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 21 Mar 2024 16:43:15 -0400 Subject: [PATCH] optimise --- .../internal/client/dom/elements/transitions.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/svelte/src/internal/client/dom/elements/transitions.js b/packages/svelte/src/internal/client/dom/elements/transitions.js index 742887aed1..0b644ea7aa 100644 --- a/packages/svelte/src/internal/client/dom/elements/transitions.js +++ b/packages/svelte/src/internal/client/dom/elements/transitions.js @@ -97,10 +97,16 @@ export function animation(element, get_fn, get_params) { animation?.abort(); - // TODO bail if `from` and `to` match - animation = animate(this.element, options, undefined, 1, () => { - animation = undefined; - }); + if ( + from.left !== to.left || + from.right !== to.right || + from.top !== to.top || + from.bottom !== to.bottom + ) { + animation = animate(this.element, options, undefined, 1, () => { + animation = undefined; + }); + } } };