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

senangwebs-animations

v1.1.4

Published

Lightweight library that enables smooth, customizable animations for HTML elements as they enter the viewport during scrolling.

Downloads

666

Readme

SenangWebs Learn more at SenangWebs.com

SenangWebs Animations (SWA)

SenangWebs Animations (SWA) is a lightweight JavaScript library that enables smooth, customizable animations for HTML elements as they enter the viewport during scrolling. With minimal setup, you can add engaging animations to your web pages, enhancing the user experience.

Features

  • Easy to integrate with existing projects
  • Supports various animation types: fade, flip, zoom, slide, and bounce
  • Customizable animation parameters via data attributes
  • Group animations with simultaneous or sequential timing
  • Efficient performance using Intersection Observer API
  • Global configuration options
  • Responsive and works on all modern browsers

Examples

https://unpkg.com/senangwebs-animations@latest/examples/index.html

Installation

Using npm

npm install senangwebs-animations

Using a CDN

You can include SenangWebs Animations directly in your HTML file using unpkg:

<link rel="stylesheet" href="https://unpkg.com/senangwebs-animations@latest/dist/swa.css">
<script src="https://unpkg.com/senangwebs-animations@latest/dist/swa.js"></script>

Usage

  1. Include the SWA CSS and JavaScript files in your HTML:
<!-- If installed via npm -->
<link rel="stylesheet" href="path/to/swa.css">
<script src="path/to/swa.js"></script>

<!-- Or if using unpkg -->
<link rel="stylesheet" href="https://unpkg.com/senangwebs-animations@latest/dist/swa.css">
<script src="https://unpkg.com/senangwebs-animations@latest/dist/swa.js"></script>
  1. Initialize the library in your JavaScript code:
document.addEventListener('DOMContentLoaded', function() {
  SWA.init({
    // Optional global configuration
    offset: 120,
    duration: 600,
    easing: 'ease-out',
    once: true,
  });
});
  1. Add data attributes to the HTML elements you want to animate:
<div
  data-swa="fade-up"
  data-swa-offset="200"
  data-swa-delay="50"
  data-swa-duration="1000"
  data-swa-easing="ease-in-out"
  data-swa-mirror="true"
  data-swa-once="false"
  data-swa-anchor-placement="top-center"
>
  This element will animate when scrolled into view.
</div>
  1. For group animations, use the data-swa-group attribute:
<div 
  data-swa-group="fade-up"
  data-swa-group-type="sequence"
  data-swa-group-interval-duration="500"
  data-swa-group-offset="200"
  data-swa-group-delay="100"
  data-swa-group-duration="1000"
  data-swa-group-easing="ease-in-out"
  data-swa-group-mirror="true"
  data-swa-group-once="false"
>
  <div>Child 1</div>
  <div>Child 2</div>
  <div>Child 3</div>
</div>

Configuration Options

Individual Element Options

You can configure animations for individual elements using the following attributes:

  • data-swa: Animation type (e.g., "fade-up", "flip-left", "zoom-in", "slide-right", "bounce-in")
  • data-swa-offset: Distance (in pixels) from the viewport before triggering the animation
  • data-swa-delay: Delay before starting the animation (in milliseconds)
  • data-swa-duration: Duration of the animation (in milliseconds)
  • data-swa-easing: Easing function for the animation (e.g., "ease-in-out", "linear")
  • data-swa-mirror: When set to "true", the animation repeats when scrolling back up
  • data-swa-once: If "true", the animation only occurs once
  • data-swa-anchor-placement: The anchor point of the element for animation start (e.g., "top-center", "center-bottom")

Group Animation Options

Group animations use similar options, but with a group prefix:

  • data-swa-group: Animation type for all children (overridden by individual data-swa on children)
  • data-swa-group-type: "simultaneous" (default) or "sequence"
  • data-swa-group-interval-duration: Time interval between animations for "sequence" type (in milliseconds)
  • data-swa-group-offset: Offset for the entire group
  • data-swa-group-delay: Delay before starting the group animation
  • data-swa-group-duration: Duration for each animation in the group
  • data-swa-group-easing: Easing function for the group animations
  • data-swa-group-mirror: Mirror setting for the group
  • data-swa-group-once: Once setting for the group
  • data-swa-group-anchor-placement: Anchor placement for the group

Supported Animations

  • Fade: fade, fade-up, fade-down, fade-left, fade-right, fade-up-left, fade-up-right, fade-down-left, fade-down-right
  • Flip: flip-up, flip-down, flip-left, flip-right
  • Zoom: zoom-in, zoom-out
  • Slide: slide-up, slide-down, slide-left, slide-right, slide-up-left, slide-up-right, slide-down-left, slide-down-right
  • Bounce: bounce-in, bounce-out

Browser Support

SenangWebs Animations works on all modern browsers that support the Intersection Observer API, including:

  • Chrome 51+
  • Firefox 55+
  • Safari 12.1+
  • Edge 15+
  • Opera 38+

For older browsers, consider using a polyfill for the Intersection Observer API.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments

  • Inspired by various scroll animation libraries in the web development community
  • Thanks to all contributors who have helped to improve this library

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

Happy animating!