Animate elements in the website on scroll.
https://taimursaeed.github.io/onscroll/
Get the CSS and JS files from the /dist
folder
Include CSS and JS files in the page
<link rel="stylesheet" href="/path/onscroll-animation.css">
...
<script src="/path/onscroll-animation.js"></script>
Add attribute data-animation
to the element you wish to animate.
E.g
<div data-animation="fade">
Change animation behavior with data-animation-*
attributes.
<div
data-animation="fade"
data-animation-delay="1000"
data-animation-speed="3000"
data-animation-offset="300"
>
</div>
Controls the delay, value in milliseconds
Controls the speed, value in milliseconds. Default 1000ms
Controls the trigger point of the animation, value in px
.
data-animation
-
fade
-
fade-up
-
fade-down
-
fade-left
-
fade-right
Use onscroll-animation.css
to extend animation or change current ones. Like default distance for animation is 30px
.
You can change it to 100px
like this:
[data-animation="fade-up"] {
transform: translate(0, 100px);
}
Please feel free to contribute pull requests or create issues for bugs and feature requests.