Trig.js powers dynamic, CSS-driven animate-on-scroll effects using CSS variables and element position data, making AOS effortless. Create custom animations in CSS or use trig-animations.css for ready-made effects—full control or quick setup. Perfect for s
npm install trig-js






!npm bundle size


!npm !npm !npm !npm !jsDelivr hits (npm)

Trig.js powers dynamic, CSS-driven animate-on-scroll effects using CSS variables and element position data, making AOS effortless. Create custom animations in CSS or use trig-animations.css for ready-made effects—full control or quick setup. Perfect for storytelling websites.

See it in action here: https://idev-games.github.io/Trig-JS/
Find more examples here: https://github.com/iDev-Games/Trig-JS-Examples
Find our codepen examples here: https://codepen.io/collection/wkBWzm
Keep up to date with tutorials, examples and informtion on my dev.to: https://dev.to/idevgames
Trig-Animations.css documentation can be found here: https://idev-games.github.io/Trig-JS/animations.html
You can download from Github.
Install with NPM
``css`
npm i trig-js
Use Trig.js from a CDN
``
https://cdn.jsdelivr.net/npm/trig-js/src/trig.min.js
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.
`html`
Or just add a CDN instead
`html`
`html` `css`
.fadeIn{
opacity:0;
}
.fadeIn.trig{
animation: fadeIn 1s normal forwards ease-in-out;
}
@keyframes fadeIn {
0% {
opacity:0;
}
100% {
opacity:1;
}
}
`html` `css`
.element{
transform: translateX( var(--trig) );
}
The CSS variables you can use by adding data-trig-var="true", data-trig-pixels="true" or data-trig-degrees="true" are:
`css`
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 /
The data attribute will also update in increments of 10 so you can use CSS attribute selectors like:
`css `
[data-trig-var="50"],
[data-trig-var="60"],
[data-trig-var="70"],
[data-trig-var="80"],
[data-trig-var="90"],
[data-trig-var="100"]{
transform: translateX( var(--trig) );
}
for more control.
`html``
Check out the code of the documentation as an example.
https://github.com/iDev-Games/Trig-JS/blob/main/index.html