Home / Class/ Spring Class — svelte Architecture

Spring Class — svelte Architecture

Architecture documentation for the Spring class in index.d.ts from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  cd4784d7_ea75_7f2f_6480_2fd34a2b882c["Spring"]
  6bd9d090_a582_e05c_669e_d53d4e7245f2["index.d.ts"]
  cd4784d7_ea75_7f2f_6480_2fd34a2b882c -->|defined in| 6bd9d090_a582_e05c_669e_d53d4e7245f2
  bc9c9a2c_6c50_0397_34e2_183769022b29["constructor()"]
  cd4784d7_ea75_7f2f_6480_2fd34a2b882c -->|method| bc9c9a2c_6c50_0397_34e2_183769022b29
  19e629ad_95b6_dfe8_9acd_5f5f16b680dd["of()"]
  cd4784d7_ea75_7f2f_6480_2fd34a2b882c -->|method| 19e629ad_95b6_dfe8_9acd_5f5f16b680dd
  4d26c82e_171a_c62f_7456_6eb9b08200c5["set()"]
  cd4784d7_ea75_7f2f_6480_2fd34a2b882c -->|method| 4d26c82e_171a_c62f_7456_6eb9b08200c5
  9d6c60dd_0f90_9110_5897_8557b732db33["current()"]
  cd4784d7_ea75_7f2f_6480_2fd34a2b882c -->|method| 9d6c60dd_0f90_9110_5897_8557b732db33

Relationship Graph

Source Code

packages/svelte/types/index.d.ts lines 2024–2066

	export class Spring<T> {
		constructor(value: T, options?: SpringOpts);

		/**
		 * Create a spring whose value is bound to the return value of `fn`. This must be called
		 * inside an effect root (for example, during component initialisation).
		 *
		 * ```svelte
		 * <script>
		 * 	import { Spring } from 'svelte/motion';
		 *
		 * 	let { number } = $props();
		 *
		 * 	const spring = Spring.of(() => number);
		 * </script>
		 * ```
		 */
		static of<U>(fn: () => U, options?: SpringOpts): Spring<U>;

		/**
		 * Sets `spring.target` to `value` and returns a `Promise` that resolves if and when `spring.current` catches up to it.
		 *
		 * If `options.instant` is `true`, `spring.current` immediately matches `spring.target`.
		 *
		 * If `options.preserveMomentum` is provided, the spring will continue on its current trajectory for
		 * the specified number of milliseconds. This is useful for things like 'fling' gestures.
		 */
		set(value: T, options?: SpringUpdateOpts): Promise<void>;

		damping: number;
		precision: number;
		stiffness: number;
		/**
		 * The end value of the spring.
		 * This property only exists on the `Spring` class, not the legacy `spring` store.
		 */
		target: T;
		/**
		 * The current value of the spring.
		 * This property only exists on the `Spring` class, not the legacy `spring` store.
		 */
		get current(): T;
	}

Frequently Asked Questions

What is the Spring class?
Spring is a class in the svelte codebase, defined in packages/svelte/types/index.d.ts.
Where is Spring defined?
Spring is defined in packages/svelte/types/index.d.ts at line 2024.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free