blockless
Rich Harris 11 months ago
parent 15b47d2c55
commit 16a6b687ce

@ -269,7 +269,7 @@ export function bind_transition(element, get_fn, get_params, direction, global)
if (current_animation && current_options) { if (current_animation && current_options) {
const time = /** @type {number} */ (current_animation.currentTime); const time = /** @type {number} */ (current_animation.currentTime);
const duration = /** @type {number} */ (current_options.duration); const duration = /** @type {number} */ (current_options.duration);
p = (current_delta * time) / duration; p = (Math.abs(current_delta) * time) / duration;
current_animation.cancel(); current_animation.cancel();
} }
@ -289,7 +289,8 @@ export function bind_transition(element, get_fn, get_params, direction, global)
current_delta = target - p; current_delta = target - p;
for (let i = 0; i <= n; i += 1) { 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); const css = current_options.css(t, 1 - t);
keyframes.push(css_to_keyframe(css)); keyframes.push(css_to_keyframe(css));
} }

@ -73,6 +73,7 @@ class Animation {
} }
this.#cancelled(); this.#cancelled();
raf.animations.delete(this);
} }
_update() { _update() {

@ -18,8 +18,9 @@ export default test({
raf.tick(150); raf.tick(150);
assert.htmlEqual( assert.htmlEqual(
target.innerHTML, target.innerHTML,
'<p>foo</p><p class="red svelte-1yszte8 border" style="overflow: hidden; opacity: 0; border-top-width: 0.5000600024000317px; border-bottom-width: 0.5000600024000317px;">bar</p>' '<p>foo</p><p class="red svelte-1yszte8 border" style="overflow: hidden; opacity: 0; border-top-width: 0.5px; border-bottom-width: 0.5px;">bar</p>'
); );
component.open = true; component.open = true;
raf.tick(250); raf.tick(250);
assert.htmlEqual( assert.htmlEqual(

Loading…
Cancel
Save