Home / Function/ set() — svelte Function Reference

set() — svelte Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  a360a3a5_5250_4fe5_418b_2dcc66c19942["set()"]
  9dd00a1e_af31_d3bc_bd26_41f120a8c8f9["Spring"]
  a360a3a5_5250_4fe5_418b_2dcc66c19942 -->|defined in| 9dd00a1e_af31_d3bc_bd26_41f120a8c8f9
  1be4451f_f9ee_5df1_6b9b_d5f88ec472fd["spring()"]
  1be4451f_f9ee_5df1_6b9b_d5f88ec472fd -->|calls| a360a3a5_5250_4fe5_418b_2dcc66c19942
  7fa90859_da7c_1cac_019f_b98ccaa8f43f["of()"]
  7fa90859_da7c_1cac_019f_b98ccaa8f43f -->|calls| a360a3a5_5250_4fe5_418b_2dcc66c19942
  938b712b_1a7d_f851_13bc_11eabf638f12["value()"]
  938b712b_1a7d_f851_13bc_11eabf638f12 -->|calls| a360a3a5_5250_4fe5_418b_2dcc66c19942
  11c1d266_b639_c6f3_311f_d778dfe898a0["damping()"]
  11c1d266_b639_c6f3_311f_d778dfe898a0 -->|calls| a360a3a5_5250_4fe5_418b_2dcc66c19942
  3b28fa12_7e5e_736c_520f_cbe43fa07140["precision()"]
  3b28fa12_7e5e_736c_520f_cbe43fa07140 -->|calls| a360a3a5_5250_4fe5_418b_2dcc66c19942
  d6aae053_5f8d_e441_a098_0d46759aba72["stiffness()"]
  d6aae053_5f8d_e441_a098_0d46759aba72 -->|calls| a360a3a5_5250_4fe5_418b_2dcc66c19942
  59d84719_cdc3_0092_0282_30b1fd8ee295["target()"]
  59d84719_cdc3_0092_0282_30b1fd8ee295 -->|calls| a360a3a5_5250_4fe5_418b_2dcc66c19942
  63ee8247_ada4_9f1d_e139_0c1167cd5b1c["set()"]
  a360a3a5_5250_4fe5_418b_2dcc66c19942 -->|calls| 63ee8247_ada4_9f1d_e139_0c1167cd5b1c
  ca823eda_572f_96a7_a6c1_3275230578c1["deferred()"]
  a360a3a5_5250_4fe5_418b_2dcc66c19942 -->|calls| ca823eda_572f_96a7_a6c1_3275230578c1
  5d33d764_c539_b815_fe49_97b00f61f68e["update()"]
  a360a3a5_5250_4fe5_418b_2dcc66c19942 -->|calls| 5d33d764_c539_b815_fe49_97b00f61f68e
  style a360a3a5_5250_4fe5_418b_2dcc66c19942 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/motion/spring.js lines 298–323

	set(value, options) {
		this.#deferred?.reject(new Error('Aborted'));

		if (options?.instant || this.#current.v === undefined) {
			this.#task?.abort();
			this.#task = null;
			set(this.#current, set(this.#target, value));
			this.#last_value = value;
			return Promise.resolve();
		}

		if (options?.preserveMomentum) {
			this.#inverse_mass = 0;
			this.#momentum = options.preserveMomentum;
		}

		var d = (this.#deferred = deferred());
		d.promise.catch(noop);

		this.#update(value).then(() => {
			if (d !== this.#deferred) return;
			d.resolve(undefined);
		});

		return d.promise;
	}

Subdomains

Frequently Asked Questions

What does set() do?
set() is a function in the svelte codebase, defined in packages/svelte/src/motion/spring.js.
Where is set() defined?
set() is defined in packages/svelte/src/motion/spring.js at line 298.
What does set() call?
set() calls 3 function(s): deferred, set, update.
What calls set()?
set() is called by 7 function(s): damping, of, precision, spring, stiffness, target, value.

Analyze Your Own Codebase

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

Try Supermodel Free