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

alpinejs-animate

v0.1.3

Published

An Alpine.js plugin to animate your website.

Downloads

15

Readme

Alpinejs Animate

This package provides a simple way to animate elements using Alpine.js and Animate.css.

Requirements

Installation

npm install alpinejs-animate

Importing

You can import the package in your JavaScript file:

import Animate from 'alpinejs-animate';

Alpine.plugin(Animate);

Alpine.start();

Note: Animate can be changed to any name you prefer.

import AlpineAnimate from 'alpinejs-animate';

Alpine.plugin(AlpineAnimate);

Alpine.start();

Basic Usage

<div x-animate="animationName">
    Content to animate
</div>

Replace animationName with any valid Animate.css animation name (e.g., "fadeIn", "bounceOut", etc.).

Modifiers

Intersection Observer

  • .intersect: Triggers the animation when the element enters the viewport.
<div x-animate.intersect="fadeIn">
    Animate when in viewport
</div>

Delay

  • .delay.[milliseconds]: Adds a delay before the animation starts.
<div x-animate.delay.500="bounceIn">
    Animate after 500ms delay
</div>

Repeat

  • .repeat.[count]: Repeats the animation a specified number of times.
  • .repeat.infinite: Repeats the animation indefinitely.
<div x-animate.repeat.3="pulse">
    Animate 3 times
</div>

Interval

  • .interval.[milliseconds]: Sets the interval between repeated animations.
  • .repeat.[count].[interval]: Repeats the animation a specified number of times.
<div x-animate.repeat.3.interval.1000="flash">
    Animate 3 times with 1 second interval
</div>

or

<div x-animate.repeat.3.100="pulse">
    Animate 3 times with 100ms interval
</div>

Duration

  • .duration.[milliseconds]: Sets the duration of each animation.
<div x-animate.duration.2000="fadeIn">
    Fade in over 2 seconds
</div>

Intersection Threshold

  • .threshold.[value]: Sets the intersection threshold (0-100).
  • .half: Sets the intersection threshold to 50%.
  • .full: Sets the intersection threshold to 99%.
<div x-animate.intersect.threshold.75="slideInUp">
    Animate when 75% visible
</div>

Combining Modifiers

You can combine multiple modifiers to create complex animation behaviors:

<div x-animate.intersect.delay.100.repeat.3.interval.500.duration.1000="bounce">
    Complex animation example
</div>

This will:

  1. Trigger when the element intersects the viewport
  2. Wait 100ms before starting
  3. Repeat the animation 3 times
  4. Wait 500ms between each repetition
  5. Each animation lasts 1000ms

Advanced Usage Examples

<div x-data>
    <!-- Animate on intersection with 100ms delay, repeat 3 times every 100ms, and each animation lasts 500ms -->
    <div x-animate.intersect.delay.100.repeat.3.interval.100.duration.500>
        Content to animate with 100ms delay on intersection, repeating 3 times every 100ms, animation duration 500ms
    </div>
    <!-- Animate on intersection without delay, repeat infinitely every 500ms, and each animation lasts 800ms -->
    <div x-animate.intersect.repeat.infinite.interval.500.duration.800>
        Content to animate on intersection without delay, repeating infinitely every 500ms, animation duration 800ms
    </div>
    <!-- Animate immediately with 100ms delay, repeat 2 times every 200ms, and each animation lasts 600ms -->
    <div x-animate.delay.100.repeat.2.interval.200.duration.600>
        Content to animate with 100ms delay immediately, repeating 2 times every 200ms, animation duration 600ms
    </div>
    <!-- Animate immediately without delay, repeat once, and animation duration 400ms -->
    <div x-animate.duration.400>
        Content to animate without delay immediately, animation duration 400ms
    </div>
</div>

Notes

  • The directive automatically adds the animate__animated class and prefixes your animation name with animate__.
  • Elements are initially hidden with the invisible class and revealed when the animation starts.
  • When using .intersect, the animation only triggers once when the element enters the viewport.

Remember to include the Animate.css library in your project for the animations to work.

Example of including Animate.css in your project

Using a CDN

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css">

Using npm

npm install animate.css

and then import it in your JavaScript file:

import 'animate.css';

or in your CSS file:

@import 'animate.css';

License

This package is open-sourced software licensed under the MIT license.

Credits

This package is heavily inspired by the following projects:

And uses the following libraries:

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Would you like me to explain or clarify any part of this documentation further?