Skip to content

Commit d0e3664

Browse files
committed
more consolidation
1 parent b76ea5f commit d0e3664

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

packages/svelte/src/motion/private.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export interface SpringUpdateOpts {
2424
* @deprecated Only use this for the spring store; does nothing when set on the Spring class
2525
*/
2626
soft?: string | number | boolean;
27+
/**
28+
* Only use this for the Spring class; does nothing when set on the spring store
29+
*/
30+
instant?: boolean;
31+
/**
32+
* Only use this for the Spring class; does nothing when set on the spring store
33+
*/
34+
preserveMomentum?: number;
2735
}
2836

2937
export type Updater<T> = (target_value: T, value: T) => T;

packages/svelte/src/motion/public.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class Spring<T> {
5858
* If `options.preserveMomentum` is provided, the spring will continue on its current trajectory for
5959
* the specified number of milliseconds. This is useful for things like 'fling' gestures.
6060
*/
61-
set(value: T, options?: { instant?: boolean; preserveMomentum?: number }): Promise<void>;
61+
set(value: T, options?: SpringUpdateOpts): Promise<void>;
6262

6363
damping: number;
6464
precision: number;

packages/svelte/src/motion/spring.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export function spring(value, opts = {}) {
133133
});
134134
}
135135
/** @type {SpringStore<T>} */
136+
// @ts-expect-error - class-only properties are missing
136137
const spring = {
137138
set,
138139
update: (fn, opts) => set(fn(/** @type {T} */ (target_value), /** @type {T} */ (value)), opts),
@@ -271,7 +272,7 @@ export class Spring {
271272
* the specified number of milliseconds. This is useful for things like 'fling' gestures.
272273
*
273274
* @param {T} value
274-
* @param {{ instant?: boolean; preserveMomentum?: number }} [options]
275+
* @param {SpringUpdateOpts} [options]
275276
*/
276277
set(value, options) {
277278
this.#deferred?.reject(new Error('Aborted'));

packages/svelte/types/index.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ declare module 'svelte/motion' {
16941694
* If `options.preserveMomentum` is provided, the spring will continue on its current trajectory for
16951695
* the specified number of milliseconds. This is useful for things like 'fling' gestures.
16961696
*/
1697-
set(value: T, options?: { instant?: boolean; preserveMomentum?: number }): Promise<void>;
1697+
set(value: T, options?: SpringUpdateOpts): Promise<void>;
16981698

16991699
damping: number;
17001700
precision: number;
@@ -1745,6 +1745,14 @@ declare module 'svelte/motion' {
17451745
* @deprecated Only use this for the spring store; does nothing when set on the Spring class
17461746
*/
17471747
soft?: string | number | boolean;
1748+
/**
1749+
* Only use this for the Spring class; does nothing when set on the spring store
1750+
*/
1751+
instant?: boolean;
1752+
/**
1753+
* Only use this for the Spring class; does nothing when set on the spring store
1754+
*/
1755+
preserveMomentum?: number;
17481756
}
17491757

17501758
type Updater<T> = (target_value: T, value: T) => T;

0 commit comments

Comments
 (0)