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

lazyanimate

v1.1.1

Published

Use CSS animations on load or scroll.

Readme

Lazy Animate

Use CSS animations on load or scroll.

Installation

  1. Install package as dependency

    yarn add lazyanimate
    # or
    npm install lazyanimate
  2. Import functions in your script and create an instance

    import LazyAnimate from 'lazyanimate'
    
    const lazyAnimate = new LazyAnimate()

Basic Usage

Lazy animate an element by adding a class of lazyanimate and a data-animate attribute with the CSS keyframes animation name:

<!-- HTML -->
<div class="my-div lazyanimate" data-animate="slide-in"></div>

Add CSS animation keyframes and apply duration and timing function:

Note that you should not apply the animation name to your elements as lazyanimate will do this for you via the data-animate attribute.

/* CSS */
.my-div {
  animation-duration: 1s;
  animation-timing-function: ease-in-out;
}

@keyframes slide-in {
  from {
    transform: translateX(-60px);
  }
}

Initialize lazyanimate in your JavaScript:

import LazyAnimate from 'lazyanimate'

const lazyAnimate = new LazyAnimate()
lazyAnimate.lazyAnimateAllOnLoad()

data-animate attribute

The data-animate attribute accepts either a string or a JavaScript object.

If a string is passed in, the element will have the CSS property animation-name applied to it when your lazyAnimate JS triggers it.

Eg: data-animate="slide-in"

If a JS object is passed in, you can apply any css property prefixed with animation-.

data-animate="{ name: '', delay: 0, direction: '', duration: 0, fillMode: '',
iterationCount: 1, playState: '', timingFunction: '' }"

You can also change the animation name using a media query string. You should have one key with a value of true which will be the fallback animation.

data-animate="{ name: { 'slide-in': true, 'slide-in-tablet': '(min-width:
768px)' } }"

API

lazyAnimateAllOnLoad

Loads all lazyanimate animations on load or instantly if already loaded.

import LazyAnimate from 'lazyanimate'

const lazyAnimate = new LazyAnimate()
lazyAnimate.lazyAnimateAllOnLoad()

lazyAnimateElement

Applies a CSS animation to an element based on it's data-animate.

import LazyAnimate from 'lazyanimate'

const el = document.getElementById('...')

const lazyAnimate = new LazyAnimate()
lazyAnimate.lazyAnimateElement(el)

lazyAnimateOnScroll

Applies lazy animate to all elements when intersection observer fires.

import LazyAnimate from 'lazyanimate'

const scrollContainer = document.getElementById('...')
const thresholdPercent = 0.8

const lazyAnimate = new LazyAnimate()
lazyAnimate.lazyAnimateOnScroll(scrollContainer, thresholdPercent)