fix: Make Tween work with continuous target changes (#14895)

* Read previous_value at a later stage in Tween.set

* Add changeset

* tweak

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/14918/head
Matthijs 3 weeks ago committed by GitHub
parent dbdb8cd7fd
commit a646780109
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: make Tween work with continuous target changes

@ -230,7 +230,6 @@ export class Tween {
set(value, options) {
set(this.#target, value);
let previous_value = this.#current.v;
let previous_task = this.#task;
let started = false;
@ -254,10 +253,12 @@ export class Tween {
if (!started) {
started = true;
fn = interpolate(/** @type {any} */ (previous_value), value);
const prev = this.#current.v;
fn = interpolate(prev, value);
if (typeof duration === 'function') {
duration = duration(/** @type {any} */ (previous_value), value);
duration = duration(prev, value);
}
previous_task?.abort();

Loading…
Cancel
Save