Skip to content

Commit 1843090

Browse files
committed
preserveMomentum in milliseconds
1 parent dc66e62 commit 1843090

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/svelte/src/motion/spring.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export class Spring {
229229
if (!this.#task) {
230230
this.#last_time = raf.now();
231231

232-
var inv_mass_recovery_rate = 1 / (this.#momentum * 60);
232+
var inv_mass_recovery_rate = 1000 / (this.#momentum * 60);
233233

234234
this.#task ??= loop((now) => {
235235
this.#inverse_mass = Math.min(this.#inverse_mass + inv_mass_recovery_rate, 1);
@@ -268,7 +268,7 @@ export class Spring {
268268
* If `options.instant` is `true`, `spring.current` immediately matches `spring.target`.
269269
*
270270
* If `options.preserveMomentum` is provided, the spring will continue on its current trajectory for
271-
* the specified number of seconds. This is useful for things like 'fling' gestures.
271+
* the specified number of milliseconds. This is useful for things like 'fling' gestures.
272272
*
273273
* @param {T} value
274274
* @param {{ instant?: boolean; preserveMomentum?: number }} [options]

packages/svelte/types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,14 +1737,14 @@ declare module 'svelte/motion' {
17371737
* If `options.instant` is `true`, `spring.current` immediately matches `spring.target`.
17381738
*
17391739
* If `options.preserveMomentum` is provided, the spring will continue on its current trajectory for
1740-
* the specified number of seconds. This is useful for things like 'fling' gestures.
1740+
* the specified number of milliseconds. This is useful for things like 'fling' gestures.
17411741
*
17421742
*
17431743
*/
17441744
set(value: T, options?: {
17451745
instant?: boolean;
17461746
preserveMomentum?: number;
1747-
} | undefined): Promise<any>;
1747+
} | undefined): Promise<unknown>;
17481748
get current(): T;
17491749
set damping(v: number);
17501750
get damping(): number;

0 commit comments

Comments
 (0)