Skip to content

Commit a646780

Browse files
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 <[email protected]>
1 parent dbdb8cd commit a646780

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.changeset/violet-cows-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: make Tween work with continuous target changes

packages/svelte/src/motion/tweened.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ export class Tween {
230230
set(value, options) {
231231
set(this.#target, value);
232232

233-
let previous_value = this.#current.v;
234233
let previous_task = this.#task;
235234

236235
let started = false;
@@ -254,10 +253,12 @@ export class Tween {
254253
if (!started) {
255254
started = true;
256255

257-
fn = interpolate(/** @type {any} */ (previous_value), value);
256+
const prev = this.#current.v;
257+
258+
fn = interpolate(prev, value);
258259

259260
if (typeof duration === 'function') {
260-
duration = duration(/** @type {any} */ (previous_value), value);
261+
duration = duration(prev, value);
261262
}
262263

263264
previous_task?.abort();

0 commit comments

Comments
 (0)