set() — svelte Function Reference
Architecture documentation for the set() function in tweened.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD eba6d905_b0bc_b5a4_beb4_5636a78d57a5["set()"] 97ee19d7_08c4_87a4_93c0_06e41fb303a5["Tween"] eba6d905_b0bc_b5a4_beb4_5636a78d57a5 -->|defined in| 97ee19d7_08c4_87a4_93c0_06e41fb303a5 cc3dbfb4_f7d6_e5af_e4aa_42d1354dade9["tweened()"] cc3dbfb4_f7d6_e5af_e4aa_42d1354dade9 -->|calls| eba6d905_b0bc_b5a4_beb4_5636a78d57a5 55807212_ec7e_a41c_d7c1_e4936fc3b4bd["of()"] 55807212_ec7e_a41c_d7c1_e4936fc3b4bd -->|calls| eba6d905_b0bc_b5a4_beb4_5636a78d57a5 640bbf01_c0ba_f7f2_eaf0_bf87c2f8741c["target()"] 640bbf01_c0ba_f7f2_eaf0_bf87c2f8741c -->|calls| eba6d905_b0bc_b5a4_beb4_5636a78d57a5 63ee8247_ada4_9f1d_e139_0c1167cd5b1c["set()"] eba6d905_b0bc_b5a4_beb4_5636a78d57a5 -->|calls| 63ee8247_ada4_9f1d_e139_0c1167cd5b1c 06e615dd_b546_019b_150f_91f3aec71a6b["now()"] eba6d905_b0bc_b5a4_beb4_5636a78d57a5 -->|calls| 06e615dd_b546_019b_150f_91f3aec71a6b 185b398a_1ddd_d231_9999_8110452fa052["loop()"] eba6d905_b0bc_b5a4_beb4_5636a78d57a5 -->|calls| 185b398a_1ddd_d231_9999_8110452fa052 style eba6d905_b0bc_b5a4_beb4_5636a78d57a5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/motion/tweened.js lines 239–293
set(value, options) {
set(this.#target, value);
let {
delay = 0,
duration = 400,
easing = linear,
interpolate = get_interpolator
} = { ...this.#defaults, ...options };
if (duration === 0) {
this.#task?.abort();
set(this.#current, value);
return Promise.resolve();
}
const start = raf.now() + delay;
/** @type {(t: number) => T} */
let fn;
let started = false;
let previous_task = this.#task;
this.#task = loop((now) => {
if (now < start) {
return true;
}
if (!started) {
started = true;
const prev = this.#current.v;
fn = interpolate(prev, value);
if (typeof duration === 'function') {
duration = duration(prev, value);
}
previous_task?.abort();
}
const elapsed = now - start;
if (elapsed > /** @type {number} */ (duration)) {
set(this.#current, value);
return false;
}
set(this.#current, fn(easing(elapsed / /** @type {number} */ (duration))));
return true;
});
return this.#task.promise;
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does set() do?
set() is a function in the svelte codebase, defined in packages/svelte/src/motion/tweened.js.
Where is set() defined?
set() is defined in packages/svelte/src/motion/tweened.js at line 239.
What does set() call?
set() calls 3 function(s): loop, now, set.
What calls set()?
set() is called by 3 function(s): of, target, tweened.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free