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

trig-js

v2.2.1

Published

The easy way to create CSS scroll animations that react to the position of your HTML element on screen. Animate on scroll (AOS) your CSS.

Downloads

59

Readme

iDev-Games - Trig-JS stars - Trig-JS

Stargazers repo roster for @iDev-Games/Trig-JS

GitHub tag License npm bundle size Codacy Badge Maintainability

npm npm npm npm jsDelivr hits (npm)

The easy way to create CSS scroll animations that react to the position of your HTML element on screen. Animate on scroll (AOS) your CSS.

See it in action here: https://idev-games.github.io/Trig-JS/

Find more examples here: https://github.com/iDev-Games/Trig-JS-Examples

You can download from Github.

Install with NPM

npm i trig-js

Use Trig.js from a CDN

https://cdn.jsdelivr.net/npm/trig-js/src/trig.min.js

What is Trig.js?

Trig.js is a super simple, efficient and lightweight way of making CSS scroll animations that react to the position of your HTML elements. You can also use Trig.js to trigger CSS animations once an element appears on screen.

Using nothing but the power of CSS, HTML and Trig.js. You can make the same effects as you see here: https://idev-games.github.io/Trig-JS/! Not just that, Trig.js is really lightweight with a filesize of npm bundle size! Trig.js is created with javascript and doesn't require any dependencies.

Trig.js is really simple and quick to work with. You can use Trig.js even if you arn't familiar with javascript.

Trig.js is the perfect solution for CSS scroll animations in any project by developers of any skill level for both light or heavy usage. Making it the perfect alternative to libraries like scrollmagic or GSAP scrolltrigger for most of your website animation needs.

How To Install?

All you need to do is add the dist trig.js file into your projects JS folder and add the following code with your trig.js location as the src. Put this code in to your head HTML tags

<script src="/js/trig.js"></script>

Or just add a CDN instead

<script src="https://cdn.jsdelivr.net/npm/trig-js/src/trig.min.js"></script>

How To Use?

To activate trig.js add the data attribute "data-trig" or a class "enable-trig" to your html element. To trigger animations trig.js will place a class of "trig" onto your element when it appears on screen.

<div class="fadeIn" data-trig> </div>
.fadeIn{ 
    opacity:0;
}
.fadeIn.trig{ 
    animation: fadeIn 1s normal forwards ease-in-out; 
}
@keyframes fadeIn { 
  0% { 
    opacity:0;
  } 
  100% { 
    opacity:1; 
  } 
}

Scroll Animations

Trig.js calculates the percentage that the element is on screen and creates CSS variables that you can use with CSS transform etc.

<div class="element" data-trig> </div>
.element{ 
    transform: translateX( var(--trig) );
}

The CSS variables you can use are:

var(--trig) /* Percentage */
var(--trig-reverse) /* Reverse percentage */
var(--trig-px) /* Pixels */
var(--trig-px-reverse) /* Reverse pixels */
var(--trig-deg) /* Degrees */
var(--trig-deg-reverse) /* Reverse degrees */

Scroll Direction

Trig.js creates a class of "trig-scroll-up" or "trig-scroll-down" onto the body of the document depending on the last scroll direction.

Scroll Position

Trig.js creates a class of "trig-scroll-top" or "trig-scroll-bottom" onto the body of the document depending on the last scroll position. To give the ability to make something happen at different break points down the page. The classes "trig-scroll-25", "trig-scroll-50" and "trig-scroll-75" are added to the body of the document depending on the scroll position percentage down the page.

Data Attributes

You can use the below data attributes for additional features

<div id="yourelement" data-trig-min="-100" data-trig-max="100" data-trig-offset="0" data-trig-negativeOffset="0" data-trig-height="0" data-trig-global="false" data-trig> </div>

Check out the code of the documentation as an example.

https://github.com/iDev-Games/Trig-JS/blob/main/index.html