Skip to main content

svelte/motion

import { function spring<T = any>(value?: T | undefined, opts?: SpringOpts | undefined): Spring<T>

The spring function in Svelte creates a store whose value is animated, with a motion that simulates the behavior of a spring. This means when the value changes, instead of transitioning at a steady rate, it “bounces” like a spring would, depending on the physics parameters provided. This adds a level of realism to the transitions and can enhance the user experience.

spring
, function tweened<T>(value?: T | undefined, defaults?: TweenedOptions<T> | undefined): Tweened<T>

A tweened store in Svelte is a special type of store that provides smooth transitions between state values over time.

tweened
} from 'svelte/motion';

spring

The spring function in Svelte creates a store whose value is animated, with a motion that simulates the behavior of a spring. This means when the value changes, instead of transitioning at a steady rate, it “bounces” like a spring would, depending on the physics parameters provided. This adds a level of realism to the transitions and can enhance the user experience.

function spring<T = any>(
	value?: T | undefined,
	opts?: SpringOpts | undefined
): Spring<T>;

tweened

A tweened store in Svelte is a special type of store that provides smooth transitions between state values over time.

function tweened<T>(
	value?: T | undefined,
	defaults?: TweenedOptions<T> | undefined
): Tweened<T>;

Spring

interface Spring<T> extends Readable<T> {}
set: (new_value: T, opts?: SpringUpdateOpts) => Promise<void>;
update: (fn: Updater<T>, opts?: SpringUpdateOpts) => Promise<void>;
precision: number;
damping: number;
stiffness: number;

Tweened

interface Tweened<T> extends Readable<T> {}
set(value: T, opts?: TweenedOptions<T>): Promise<void>;
update(updater: Updater<T>, opts?: TweenedOptions<T>): Promise<void>;

Edit this page on GitHub