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 🙏

© 2024 – Pkg Stats / Ryan Hefner

lottie-svelte

v1.3.7

Published

A very simple Svetle wrapper around `lottie-web`, made with TypeScript.

Downloads

1,031

Readme

lottie-svelte

A very simple Svetle wrapper around lottie-web, made with TypeScript.

Exposes the underlying lottie-web API if you need it.

Programmatically control animations.

Example #1:

<script>
    import { Lottie } from 'lottie-svelte';
</script>

<Lottie path="./love.json" speed={0.2}/>

https://stackblitz.com/edit/vitejs-vite-59zcbv?file=src/App.svelte

Example #2:

Common properties available via props.

<script>
    import { Lottie } from 'lottie-svelte';
    import { Direction } from 'lottie-svelte/iface';
</script>

<Lottie
    path="./love.json"
    autoplay={true}
    loop={false}
    speed={0.2}
    direction={Direction.REVERSE}
/>

https://stackblitz.com/edit/vitejs-vite-wtauwm?file=src/App.svelte

Lottie component props:

| Prop | type | required | description | | --- | --- | --- | --- | | path | string | ✅ | The path to the lottie file, relative to the static directory. E.g. for a lottie file located at static/lottie/heart.json, you would pass in ./lottie/heart.json to this prop. | | loop | boolean | ⏩ | Whether the lottie should loop when it finishes. Default true. | | autoplay | boolean | ⏩ | Whether the lottie should autoplay once it loads. Default true. | | speed | number | ⏩ | Default 1. The speed that the animation should play. Float, 2 is 2x, 0.5 is half speed etc. | | direction | Direction | ⏩ | Whether the animation plays FORWARD or in REVERSE. Default is FORWARD. Use the Direction enum in iface. FORWARD = 1, REVERSE = -1. | | name | string | ⏩ | Sometimes required by the underlying lottie-web functions. You may need to set this if you are calling underlying certain methods on the AnimationItem | | renderer | RendererType | ⏩ | How the lottie is rendered, one of 'svg' 'canvas' 'html'. Default is 'svg' | | container | HTMLElement | ⏩ | Under normal circumstances don't use this prop. A reference to an element where the lottie will be created. If left blank lottie-svelte will create one for you. |

Programmatically control animation:

In addition to setting initial speed, direction etc. We provide a convenient event that fires once the lottie animation has loaded on:animation. From this event you can get the underlying animation and control its speed, direction, frame and much more programatically. You can find the supported AnimationItem methods here

<script lang="ts">
	import { Lottie } from 'lottie-svelte';
	import type { AnimationEvent } from 'lottie-svelte/iface';

	function handler(event: AnimationEvent) {
		const animation = event.detail; // lottie-web AnimationItem
		animation.setSpeed(0.2);
		setTimeout(() => animation.pause(), 1500);
	}
</script>

<!-- Lottie file is located at static/heart.json -->
<Lottie path="./heart.json" on:animation={handler} />

https://stackblitz.com/edit/vitejs-vite-o6z51r?file=src/App.svelte