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-interactive

v1.3.2

Published

A custom element that adds interactions and quality of life changes to Lottie animations.

Downloads

2,297

Readme

alt Lottie-interactive

Lottie interactive is custom web element adding multiple types of interactivity to Lottie animations.

Installation

Lottie-interactive is availabile through npm.

npm install lottie-interactive

Lottie-interactive is also available though unpkg.

<script type="text/javascript" src="https://unpkg.com/lottie-interactive@latest/dist/lottie-interactive.js"></script>

Usage

From javascript module:

import { LottieInteractive } from 'lottie-interactive'

Usage in markup:

<lottie-interactive path="button.json" interaction="click"></lottie-interactive>

Nuxt.js

  • npm -i lottie-interactive
  • Create a plugin for lottie-interactive in /plugins/lottie-interactive.client.js:
import Vue from 'vue'
import LottieInteractive from 'lottie-interactive'

Vue.use(LottieInteractive)

You can then use lottie-interactive inside of your templates:

<template>
    <lottie-interactive
      path="/animations/svgenius-logo.json"
      autoplay
      loop
      view-box="0 0 500 300"
    />
</template>

Remarks: Animation files (.json) can be accessed if put inside the /static directory. URLs to the animation can also be used.

Next.js

  • npm -i lottie-interactive

Then inside of your pages:

import React from "react";

export default function Home() {
  React.useEffect(() => {
    import("lottie-interactive/dist/lottie-interactive.js");
  });

  return (
    <div>
          <lottie-interactive
              path="/animations/svgenius-logo.json"
              autoplay
              loop
          />
    </div>
  );
}

Remarks: Animation files (.json) can be accessed if put inside the /public/ directory. URLs to the animation can also be used.

Examples

npm i
npm start

Current interactions and available attributes

Interactions

click

Plays animation when user clicks on animation container

<lottie-interactive path="button.json" interaction="click"></lottie-interactive>
freeze click

Freezes animation when user clicks on animation container

<lottie-interactive path="button.json" interaction="freeze-click" autoplay loop></lottie-interactive>
hover

Plays animation when user hovers on animation container

<lottie-interactive path="button.json" interaction="hover"></lottie-interactive>
morph

Plays animation when user hovers on animation container, plays in reverse on 'mouseexit' event

<lottie-interactive path="button.json" interaction="morph"></lottie-interactive>
morph-lock

Plays animation when user hovers on animation container. Locks animation at the end if user clicks. Plays in reverse on 'mouseexit' event.

<lottie-interactive path="button.json" interaction="morph-lock"></lottie-interactive>
switch

Plays animation when user clicks on animation container, plays again in reverse on second click

<lottie-interactive path="button.json" interaction="switch"></lottie-interactive>
play-on-show

Plays animation when container is visible

<lottie-interactive path="button.json" interaction="play-on-show"></lottie-interactive>
play-once

Plays animation once

<lottie-interactive path="button.json" interaction="play-once"></lottie-interactive>

Attributes

The default state for attributes are false or null for stroke width and color.

loop

Makes the animation loop

<lottie-interactive path="button.json" loop></lottie-interactive>
s-width

Changes the stroke width of every stroke

<lottie-interactive path="button.json" s-width="25"></lottie-interactive>
s-color

Changes the stroke color of every stroke, must be a full hexadecimal color

<lottie-interactive path="button.json" s-color="#ffffff"></lottie-interactive>
autoplay

Makes the animation play automatically on load

<lottie-interactive path="button.json" autoplay></lottie-interactive>
speed

Sets the speed of the animation

<lottie-interactive path="button.json" speed="0.5"></lottie-interactive>
delay

Delay the loading of the animation, defined in milliseconds

<lottie-interactive path="button.json" delay="3000"></lottie-interactive>
reset

Resets the animation to the first frame after it has finished playing

<lottie-interactive path="button.json" reset></lottie-interactive>
aspect-ratio

Define aspect ratio, default value is 'xMidYMid slice', more information here

<lottie-interactive path="button.json" aspect-ratio='xMidYMid meet'></lottie-interactive>

Usage notice

Browser compatibility

Currently this library is usable on modern browsers supporting Web components and Lottie.

Bundlers

We recommend using this library with a module bundler such as webpack.

Upcoming features

  • Color on hover
  • Animation zooming
  • Padding modifier
  • Upgrade codebase to use Microsoft FAST

Youtube guides

https://www.youtube.com/channel/UCPPNxV39UlVo3emNQSNNTug

Lottie animations

https://svgenius.co

https://lottiefiles.com/svgenius