npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@288-toolkit/animations

v4.1.3

Published

```sh npm i @288-toolkit/animations ```

Readme

Animations

npm i @288-toolkit/animations

A collection of functions and actions to animate elements.

createAnimationArchitect()

An architect allows you to register animation functions that will get played when transitioning out from a page, which is useful to coordinate multiple outro animations. The architect instance has to be initialized with the provided start function in order to work, which is a wrapper around registerTransition.

The animations will not be played if the user has reduced motion.

Options

outDuration

The outro duration in ms that the animations must be played for. Default: 400.

Returns

start

A wrapper around registerTransition that initializes the architect. This function MUST be called at component initialization. It accepts the same arguments and returns the $transitioning store for the registered transition.

registerAnimation

The function to register your outro animation. The outro animation is simply a function that receives the duration in seconds and durationMs in milliseconds, which is the outDuration passed to the architect.

Example

const architect = createAnimationArchitect({ outDuration: 350 });
<script lang="ts">
	import { architect } from '$lib/animations/defaultArchitect';

	architect.start('default');
</script>

<script lang="ts">
	import {onMount} from 'svelte';

	let myEl: HTMLElement

	onMount(() => {
		architect.registerAnimation(({ durationMs }) => {
			// ... animate myEl before navigating away from the page
		})
	})
</script>

createMotionArchitect

A wrapper around createAnimationArchitect to handle Motion animations.

It accepts the same arguments and An architect instance extended with registerMotionAnimation. This function takes the animation controls returned from animate or timline and automatically reverses the animation when transitioning out.

<script lang="ts">
	onMount(() => {
		architect.registerMotionAnimation(
			animate(
				myEl,
				{
					opacity: [0, 1]
				},
				{ duration: 0.3 }
			)
		);
	});
</script>

use:playMotionAnimationInView

Plays a Motion animation when the element comes into view, using Motion's inView function. Registers it with an optional architect (see createMotionArchitect) so that if the element is in view when a navigation occurs, the animation will be reversed (which can be turned off with reverse: false). Make sure that the animation is set to autoplay: false, otherwise it will play immediately, potentially before the element is in view.

The animation will be skipped to its final state if the user has reduced motion.

Options

animation

The animation to play, returned from either animate or timeline from Motion.

animation: AnimationControls;

architect

The architect to register the animation with. If provided, the animation will be unregistered when the element is out of view and reversed if the element is in view when a navigation occurs.

architect?: ReturnType<typeof createMotionArchitect>;

reverse

Whether to reverse the animation when the element is out of view. DEFAULT: true.

reverse?: boolean;

inViewOptions

The options to pass to the inView function.

inViewOptions?: InViewOptions;

Example

<div
	use:playMotionAnimationInView={{
		animation: animate(el, {
			/*...*/
		}),
		reverse: false,
		inViewOptions: {
			amount: 0.8
		}
	}}
></div>

use:animateInView

Wraps playMotionAnimationInView and:

  • Makes sure that the animation has autoplay: false
  • Provides a nice API to select multiple elements within the node.
  • Allows disabling the animation.

Options

animateInView has the same options as playMotionAnimationInView except animation, as well as the following.

keyframes

The keyframes of the animation.

keyframes: MotionKeyframesDefinition;

options

The animation options.

options?: AnimationOptionsWithOverrides;

selector

A CSS selector find elements within the node to animate. If omitted, the node itself will be animated.

selector?: string;

disabled

Disables the animation. DEFAULT: false.

disabled?: boolean;

Example

<ul
	use:playMotionAnimationInView={{
		keyframes: {
			transform: ['translateY(4rem)', 'none'],
			opacity: [0, 1]
		},
		options: {
			transform: {
				easing: expoOut,
				duration: 0.7
			},
			opacity: {
				easing: 'linear',
				duration: 0.2
			},
			delay: stagger(0.1)
		},
		selector: 'li',
		inViewOptions: {
			amount: 0.4
		}
	}}
>
	{#each items as item}
		<li>{item}</li>
	{/each}
</ul>

use:slide

An action to animate the height of an element.It uses tweened store to animate the element, which you can configure.

[!NOTE] Why not use slide from svelte/transition? It's still a very good choice, but svelte transitions require the elements to be mounted/unmounted from the DOM to be animated. Sometimes you might want to keep the elements in the DOM, for example to get a better SEO score for the page. In that case, the slide action is prefered.

Options

open

Determines if the element is collapsed or not.

open: boolean;

options

The options of the tweened store, so you can adjust the duration, easing, etc. The duration will be overriden to 0 if the user has reduced motion.

options: Parameters < typeof tweened < number >> [1];

closedHeight

The height of the element when open is false.

closedHeight: number;

Example

<div
	use:slide={{ open: $open, options: { duration: 700, easing: expoOut }, closedHeight: 50 }}
></div>

use:parallax

Creates a parallax effect on an element using Motion. The parallax will be re-initialized when the options change, so you can update them dynamically to match certain conditions, like mobile and desktop options.

Options

speed

Speed of the animation. Negative values invert the direction. 0 disables the animation. DEFAULT: 0.2.

speed?: number;

easing

Easing of the animation. DEFAULT: 'linear'.

easing?: Easing;

keyframes

Extra keyframes to add more animation effects.

keyframes?: MotionKeyframesDefinition;

Example

<script lang="ts">
	import { createMatchMediaStore } from '@288-toolkit/device/media';

	const isDesktop = createMatchMediaStore('(min-width: 1200px)');
</script>

<div
	use:parallax={{
		speed: $isDesktop ? 0.4 : 0.2
	}}
></div>

use:parallaxFade

Adds a fade animation to the basic parallax.

Options

from

Opacity at the start of the animation. DEFAULT: 0.

from?: number;

to

Opacity at the end of the animation. DEFAULT: 1.

to?: number;

speed

Speed of the animation. Negative values invert the direction. 0 disables the animation. DEFAULT: 0.2.

speed?: number;

easing

Easing of the animation. DEFAULT: 'linear'.

easing?: Easing;

use:parallaxScale

Adds a scale animation to the basic parallax. The element has a scale of 1 at the middle of the animation.

Options

from

Scale at the start of the animation. DEFAULT: 0.5.

from?: number;

to

Scale at the end of the animation. DEFAULT: 0.5.

to?: number;

speed

Speed of the animation. Negative values invert the direction. 0 disables the animation. DEFAULT: 0.2.

speed?: number;

easing

Easing of the animation. DEFAULT: 'linear'.

easing?: Easing;

augmentedParallax()

A convenience function to augment the basic parallax action with more animation effects.

See parallaxFade and parallaxScale for examples.