Home / Function/ constructor() — svelte Function Reference

constructor() — svelte Function Reference

Architecture documentation for the constructor() function in spring.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  af9812be_2f60_26a2_5915_306d68c75160["constructor()"]
  9dd00a1e_af31_d3bc_bd26_41f120a8c8f9["Spring"]
  af9812be_2f60_26a2_5915_306d68c75160 -->|defined in| 9dd00a1e_af31_d3bc_bd26_41f120a8c8f9
  4dfcf957_8573_ff55_bd31_4181227109e3["tag()"]
  af9812be_2f60_26a2_5915_306d68c75160 -->|calls| 4dfcf957_8573_ff55_bd31_4181227109e3
  39208392_58c1_7201_b748_aa74d97cadb9["state()"]
  af9812be_2f60_26a2_5915_306d68c75160 -->|calls| 39208392_58c1_7201_b748_aa74d97cadb9
  e53c3364_4d96_7213_8c2b_7f5ca948d703["clamp()"]
  af9812be_2f60_26a2_5915_306d68c75160 -->|calls| e53c3364_4d96_7213_8c2b_7f5ca948d703
  style af9812be_2f60_26a2_5915_306d68c75160 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/motion/spring.js lines 196–211

	constructor(value, options = {}) {
		this.#current = DEV ? tag(state(value), 'Spring.current') : state(value);
		this.#target = DEV ? tag(state(value), 'Spring.target') : state(value);

		if (typeof options.stiffness === 'number') this.#stiffness.v = clamp(options.stiffness, 0, 1);
		if (typeof options.damping === 'number') this.#damping.v = clamp(options.damping, 0, 1);
		if (typeof options.precision === 'number') this.#precision.v = options.precision;

		if (DEV) {
			tag(this.#stiffness, 'Spring.stiffness');
			tag(this.#damping, 'Spring.damping');
			tag(this.#precision, 'Spring.precision');
			tag(this.#current, 'Spring.current');
			tag(this.#target, 'Spring.target');
		}
	}

Subdomains

Frequently Asked Questions

What does constructor() do?
constructor() is a function in the svelte codebase, defined in packages/svelte/src/motion/spring.js.
Where is constructor() defined?
constructor() is defined in packages/svelte/src/motion/spring.js at line 196.
What does constructor() call?
constructor() calls 3 function(s): clamp, state, tag.

Analyze Your Own Codebase

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

Try Supermodel Free