跳至主要内容

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

Svelte 中的 spring 函数创建一个其值会进行动画处理的存储,其运动模拟了弹簧的行为。这意味着当值发生变化时,它不会以稳定的速率进行过渡,而是会像弹簧一样“弹跳”,具体取决于提供的物理参数。这为过渡增加了真实感,并可以增强用户体验。

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

tweened

Svelte 中的 tweened 存储是一种特殊的存储类型,它可以随着时间的推移在状态值之间提供平滑的过渡。

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>;

在 GitHub 上编辑此页面

上一页 下一页