From 16a6b687ce922fffe2679d7af08a9c677bf0a22f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 23 Feb 2024 00:08:43 -0500 Subject: [PATCH] fix --- packages/svelte/src/internal/client/transitions.js | 5 +++-- packages/svelte/tests/animation-helpers.js | 1 + .../samples/class-shortcut-with-transition/_config.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/svelte/src/internal/client/transitions.js b/packages/svelte/src/internal/client/transitions.js index 5d63e936bc..d7b82bb1e5 100644 --- a/packages/svelte/src/internal/client/transitions.js +++ b/packages/svelte/src/internal/client/transitions.js @@ -269,7 +269,7 @@ export function bind_transition(element, get_fn, get_params, direction, global) if (current_animation && current_options) { const time = /** @type {number} */ (current_animation.currentTime); const duration = /** @type {number} */ (current_options.duration); - p = (current_delta * time) / duration; + p = (Math.abs(current_delta) * time) / duration; current_animation.cancel(); } @@ -289,7 +289,8 @@ export function bind_transition(element, get_fn, get_params, direction, global) current_delta = target - p; for (let i = 0; i <= n; i += 1) { - const t = (current_options.easing ?? linear)(p + (current_delta * i) / n); + const eased = (current_options.easing ?? linear)(i / n); + const t = p + current_delta * eased; const css = current_options.css(t, 1 - t); keyframes.push(css_to_keyframe(css)); } diff --git a/packages/svelte/tests/animation-helpers.js b/packages/svelte/tests/animation-helpers.js index 61d305d248..8b42ada089 100644 --- a/packages/svelte/tests/animation-helpers.js +++ b/packages/svelte/tests/animation-helpers.js @@ -73,6 +73,7 @@ class Animation { } this.#cancelled(); + raf.animations.delete(this); } _update() { diff --git a/packages/svelte/tests/runtime-legacy/samples/class-shortcut-with-transition/_config.js b/packages/svelte/tests/runtime-legacy/samples/class-shortcut-with-transition/_config.js index 3df138e99a..33b563c549 100644 --- a/packages/svelte/tests/runtime-legacy/samples/class-shortcut-with-transition/_config.js +++ b/packages/svelte/tests/runtime-legacy/samples/class-shortcut-with-transition/_config.js @@ -18,8 +18,9 @@ export default test({ raf.tick(150); assert.htmlEqual( target.innerHTML, - '

foo

bar

' + '

foo

bar

' ); + component.open = true; raf.tick(250); assert.htmlEqual(