Home / File/ tweened.js — svelte Source File

tweened.js — svelte Source File

Architecture documentation for tweened.js, a javascript file in the svelte codebase. 16 imports, 0 dependents.

File javascript SharedInternal DOMUtils 16 imports 2 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  99a316ef_52a9_1ecb_3a20_489761af28ad["tweened.js"]
  b874f390_a6ee_7d84_7151_b2b77f0388d5["index.js"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> b874f390_a6ee_7d84_7151_b2b77f0388d5
  ba16ff3e_8a18_d3c4_15e9_96304b539f51["writable"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> ba16ff3e_8a18_d3c4_15e9_96304b539f51
  fa5af256_aedf_fd58_ea3f_a0325a1204b6["timing.js"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> fa5af256_aedf_fd58_ea3f_a0325a1204b6
  385470d9_b5f1_1cd1_d8da_e61454f3e60a["loop.js"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> 385470d9_b5f1_1cd1_d8da_e61454f3e60a
  185b398a_1ddd_d231_9999_8110452fa052["loop"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> 185b398a_1ddd_d231_9999_8110452fa052
  8d8f0ca3_5d92_5886_ea4e_cf91e157cffe["index.js"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> 8d8f0ca3_5d92_5886_ea4e_cf91e157cffe
  060cd71c_63cf_1b7a_d7c4_54edda80f819["linear"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> 060cd71c_63cf_1b7a_d7c4_54edda80f819
  b9c3547e_c9a1_be32_9b5a_2b919c35349e["utils.js"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> b9c3547e_c9a1_be32_9b5a_2b919c35349e
  2c01da3b_6fe8_7031_6c99_5ae208e44c66["is_date"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> 2c01da3b_6fe8_7031_6c99_5ae208e44c66
  e5c35d51_28d8_9054_923d_b7f82a3c8dc2["sources.js"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> e5c35d51_28d8_9054_923d_b7f82a3c8dc2
  63ee8247_ada4_9f1d_e139_0c1167cd5b1c["set"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> 63ee8247_ada4_9f1d_e139_0c1167cd5b1c
  39208392_58c1_7201_b748_aa74d97cadb9["state"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> 39208392_58c1_7201_b748_aa74d97cadb9
  2696eb67_452f_4c32_3e13_ee172192b366["tracing.js"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> 2696eb67_452f_4c32_3e13_ee172192b366
  4dfcf957_8573_ff55_bd31_4181227109e3["tag"]
  99a316ef_52a9_1ecb_3a20_489761af28ad --> 4dfcf957_8573_ff55_bd31_4181227109e3
  style 99a316ef_52a9_1ecb_3a20_489761af28ad fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { Task } from '../internal/client/types' */
/** @import { Tweened } from './public' */
/** @import { TweenedOptions } from './private' */
import { writable } from '../store/shared/index.js';
import { raf } from '../internal/client/timing.js';
import { loop } from '../internal/client/loop.js';
import { linear } from '../easing/index.js';
import { is_date } from './utils.js';
import { set, state } from '../internal/client/reactivity/sources.js';
import { tag } from '../internal/client/dev/tracing.js';
import { get, render_effect } from 'svelte/internal/client';
import { DEV } from 'esm-env';

/**
 * @template T
 * @param {T} a
 * @param {T} b
 * @returns {(t: number) => T}
 */
function get_interpolator(a, b) {
	if (a === b || a !== a) return () => a;

	const type = typeof a;
	if (type !== typeof b || Array.isArray(a) !== Array.isArray(b)) {
		throw new Error('Cannot interpolate values of different type');
	}

	if (Array.isArray(a)) {
		const arr = /** @type {Array<any>} */ (b).map((bi, i) => {
			return get_interpolator(/** @type {Array<any>} */ (a)[i], bi);
		});

		// @ts-ignore
		return (t) => arr.map((fn) => fn(t));
	}

	if (type === 'object') {
		if (!a || !b) {
			throw new Error('Object cannot be null');
		}

		if (is_date(a) && is_date(b)) {
			const an = a.getTime();
			const bn = b.getTime();
			const delta = bn - an;

			// @ts-ignore
			return (t) => new Date(an + t * delta);
		}

		const keys = Object.keys(b);

		/** @type {Record<string, (t: number) => T>} */
		const interpolators = {};
		keys.forEach((key) => {
			// @ts-ignore
			interpolators[key] = get_interpolator(a[key], b[key]);
		});

		// @ts-ignore
// ... (247 more lines)

Subdomains

Classes

Frequently Asked Questions

What does tweened.js do?
tweened.js is a source file in the svelte codebase, written in javascript. It belongs to the SharedInternal domain, DOMUtils subdomain.
What functions are defined in tweened.js?
tweened.js defines 2 function(s): get_interpolator, tweened.
What does tweened.js depend on?
tweened.js imports 16 module(s): client, esm-env, index.js, index.js, is_date, linear, loop, loop.js, and 8 more.
Where is tweened.js in the architecture?
tweened.js is located at packages/svelte/src/motion/tweened.js (domain: SharedInternal, subdomain: DOMUtils, directory: packages/svelte/src/motion).

Analyze Your Own Codebase

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

Try Supermodel Free