Home / File/ index.js — svelte Source File

index.js — svelte Source File

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

File javascript AnimationLibrary Transitions 2 imports 12 functions

Entity Profile

Dependency Diagram

graph LR
  8795a504_2189_bf07_fb96_096bc8c92d25["index.js"]
  df278ca2_0a6c_fefe_09f2_b397500fe3c2["warnings.js"]
  8795a504_2189_bf07_fb96_096bc8c92d25 --> df278ca2_0a6c_fefe_09f2_b397500fe3c2
  c9866d91_a204_fa55_a9e3_6bcc6aaaec1e["esm-env"]
  8795a504_2189_bf07_fb96_096bc8c92d25 --> c9866d91_a204_fa55_a9e3_6bcc6aaaec1e
  style 8795a504_2189_bf07_fb96_096bc8c92d25 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { BlurParams, CrossfadeParams, DrawParams, FadeParams, FlyParams, ScaleParams, SlideParams, TransitionConfig } from './public' */

import { DEV } from 'esm-env';
import * as w from '../internal/client/warnings.js';

/** @param {number} x */
const linear = (x) => x;

/** @param {number} t */
function cubic_out(t) {
	const f = t - 1.0;
	return f * f * f + 1.0;
}

/**
 * @param {number} t
 * @returns {number}
 */
function cubic_in_out(t) {
	return t < 0.5 ? 4.0 * t * t * t : 0.5 * Math.pow(2.0 * t - 2.0, 3.0) + 1.0;
}

/** @param {number | string} value
 * @returns {[number, string]}
 */
function split_css_unit(value) {
	const split = typeof value === 'string' && value.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);
	return split ? [parseFloat(split[1]), split[2] || 'px'] : [/** @type {number} */ (value), 'px'];
}

/**
 * Animates a `blur` filter alongside an element's opacity.
 *
 * @param {Element} node
 * @param {BlurParams} [params]
 * @returns {TransitionConfig}
 */
export function blur(
	node,
	{ delay = 0, duration = 400, easing = cubic_in_out, amount = 5, opacity = 0 } = {}
) {
	const style = getComputedStyle(node);
	const target_opacity = +style.opacity;
	const f = style.filter === 'none' ? '' : style.filter;
	const od = target_opacity * (1 - opacity);
	const [value, unit] = split_css_unit(amount);
	return {
		delay,
		duration,
		easing,
		css: (_t, u) => `opacity: ${target_opacity - od * u}; filter: ${f} blur(${u * value}${unit});`
	};
}

/**
 * Animates the opacity of an element from 0 to the current opacity for `in` transitions and from the current opacity to 0 for `out` transitions.
 *
 * @param {Element} node
 * @param {FadeParams} [params]
 * @returns {TransitionConfig}
// ... (241 more lines)

Subdomains

Dependencies

Frequently Asked Questions

What does index.js do?
index.js is a source file in the svelte codebase, written in javascript. It belongs to the AnimationLibrary domain, Transitions subdomain.
What functions are defined in index.js?
index.js defines 12 function(s): assign, blur, crossfade, cubic_in_out, cubic_out, draw, fade, fly, linear, scale, and 2 more.
What does index.js depend on?
index.js imports 2 module(s): esm-env, warnings.js.
Where is index.js in the architecture?
index.js is located at packages/svelte/src/transition/index.js (domain: AnimationLibrary, subdomain: Transitions, directory: packages/svelte/src/transition).

Analyze Your Own Codebase

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

Try Supermodel Free