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-player-svelte

v0.5.3

Published

Lottie animation player sveltekit components ssr safe.

Downloads

34

Readme

SvelteKit Lottie Web Player

GitHub license GitHub issues GitHub stars GitHub forks

SvelteKit Lottie Web Player is a lightweight and easy-to-use library for integrating Lottie animations into your SvelteKit applications. This library is SSR (Server-Side Rendering) safe, providing seamless integration with SvelteKit's SSR capabilities. With SvelteKit Lottie Web Player, you can effortlessly add engaging and dynamic animations to your SvelteKit projects.

Features

  • SSR (Server-Side Rendering) safe
  • Easy integration with SvelteKit projects
  • Lightweight and efficient
  • Support for Lottie animations in JSON format
  • Customizable animation playback options

Installation

To install SvelteKit Lottie Web Player, use your preferred package manager:

npm install lottie-player-svelte
# or
yarn add lottie-player-svelte
# or
pnpm install lottie-player-svelte

Usage

  1. Import the LottieSvelte component into your SvelteKit component:
<script>
import { LottieSvelte } from 'lottie-svelte';
</script>
  1. Use the LottieSvelte component in your SvelteKit template, providing the path to your Lottie animation file:
<!-- external -->
<LottiePlayer src="/path/to/your/animation.json" />

<!-- imported src -->
<script>
import MyLottieJSON from "$lib/assets/my-lottie.json"
</script>
<LottieSvelte
  src={MyLottieJSON}
  autoplay={true}
  loop={true}
  speed={1.5}
/>
  1. Customize the animation playback options using component props:
<LottieSvelte
  src="/path/to/your/animation.json"
  autoplay={true}
  loop={true}
  speed={1.5}
/>
  1. Controls the animation by binding this
<script lang="ts">
import { LottieSvelte, type LottieSvelteInstance } from 'lottie-svelte';

let lottieSvelte: LottieSvelteInstance;

onMount(() => {
    setTimeout(() => {
        lottieSvelte?.pause()
    }, 500)
})
</script>

<LottieSvelte
    ...
    bind:this={lottieSvelte}
/>

Props

  • src (String | Object, required): The path to the Lottie animation JSON file.
  • autoplay (Boolean, optional, default: true): Whether the animation should start playing automatically.
  • background (String, optional, default: "transparent"): Background color of the player container.
  • controls (Boolean, optional, default: false): Whether to display playback controls.
  • count (Number | undefined, optional, default: undefined): Number of times to play the animation (overrides loop).
  • description (String, optional, default: "Lottie animation"): Description of the animation for accessibility.
  • direction (1 | -1, optional, default: 1): Direction of the animation playback (1 for forward, -1 for backward).
  • disableCheck (Boolean, optional, default: false): Whether to disable the animation size check.
  • disableShadowDOM (Boolean, optional, default: false): Whether to disable the Shadow DOM.
  • hover (Boolean, optional, default: false): Whether to pause the animation on hover.
  • intermission (Number, optional, default: 1): Delay in milliseconds before the animation starts.
  • loop (Boolean, optional, default: false): Whether the animation should loop.
  • mode (PlayMode, optional, default: PlayMode.Normal): Playback mode of the animation.
  • preserveAspectRatio (String, optional, default: "xMidYMid meet"): Aspect ratio preservation for the animation.
  • renderer ("svg", optional, default: "svg"): Renderer type for the animation.
  • viewBoxSize (String | undefined, optional, default: undefined): Size of the viewBox for the animation.
  • speed (Number, optional, default: 1): The playback speed of the animation.
  • webworkers (Boolean, optional, default: false): Whether to use web workers for rendering.
  • containerClass (String, optional, default: ""): Custom CSS class for the player container.
  • animationClass (String, optional, default: ""): Custom CSS class for the animation element.

Methods

  • getLottie: () => any;
  • play: () => void;
  • pause: () => void;
  • stop: () => void;
  • seek: (value: number | string) => void;
  • snapshot: (download: boolean) => string | void;
  • setSpeed: (value: number) => void;
  • setDirection: (value: AnimationDirection) => void;
  • setLooping: (value: boolean) => void;
  • togglePlay: () => void;
  • toggleLooping: () => void;
  • resize: () => void;

Emitted Events

export enum PlayerEvents {
	Complete = "complete",
	Destroyed = "destroyed",
	Error = "error",
	Frame = "frame",
	Freeze = "freeze",
	Load = "load",
	Loop = "loop",
	Pause = "pause",
	Play = "play",
	Ready = "ready",
	Rendered = "rendered",
	Stop = "stop",
}

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.