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

io-animate

v1.0.1

Published

Lightweight animation for elements by using Intersection Observer.

Downloads

4

Readme

io-Animate - Intersection Observer Animate

A pure, vanilla JavaScript, lightweight solution using Intersection Observer to animate HTML elements based on their presence in the viewport. This package comes with no built-in CSS animations, instead you can use any CSS animation library, or make your own custom animations. io-Animate simply applies those animations when the specified elements are visible. The polyfill for the Intersection Observer API is also included, so it should function properly on all devices and modern browsers.

I created this package after running into many issues with CSS animations not properly being triggered on scroll, particularily when using mobile devices or web browsers other than Chrome and Firefox. I found that using the Intersection Observer API was the most accurate when determining if an element was present in the viewport, across all devices and web browsers.

Getting Started

Prerequisites

As io-Animate comes with no CSS animations of its own, you must have existing CSS animations. The default CSS prefix for animations is animated, which is based off of animate.css by Daniel Eden.

<head>
  <link rel="stylesheet" href="path/to/your/animations.css">
</head>

Installing

Install with npm:

npm install io-animate

or yarn:

yarn add io-animate

Usage

For explanation purposes, this documentation will assume that animate.css has been pre-loaded.

Initialization

You must first initialize io-Animate inside your code, with a few configurable options:

import ioAnimate from 'io-animate'

ioAnimate(
  '.io-animate', // The document query selector for elements to be observed
  'animated', // The CSS prefix to add to elements when they are visible.
  false // a boolean that determines if the animations should only play once
)

Animations

Add the document query selector specified when initalizing io-Animate to the elements. In this example it is the CSS class io-animate

Each element must specify the animation CSS class to trigger. Optionally, you can add more classes for delay and speed times.

<div class="io-animate" data-ioa-in="fadeIn" data-ioa-out="fadeOut" data-ioa-delay="delay-1s" data-ioa-speed="slow">Once visible, this div will fade in slowly after a 1 second delay, and will fade out while scrolling out.</div>

There are 4 data attributes to configure:

| Attribute | Description | Example | | ------------- |:-------------:| --------:| | data-ioa-in | Animation when the element becomes visible. | fadeIn | | data-ioa-out | Animation when the element is not visible. | fadeOut | | data-ioa-delay | CSS class used to add animation delay. | delay-1s | | data-ioa-speed | CSS class that determines the animation speed. | slow |

Using every data attribute, the resulting CSS class of an element would look like this once visible:

<div class="io-animate animated fadeIn delay-2s slow">I will fade in.</div>

Authors

  • Wesley Moses - Initial work - wes337