Press "Enter" to skip to content

A Tiny JavaScript Library to Enable CSS Animation When The User Scrolls | onscroll-effect

On Scroll Effect, a JavaScript library with a scroll effect that automatically adds or removes CSS classes from a specific element when you scroll down/up a web page.

This library switches a class to an item when it appears in the viewport when the user scrolls. It allows you to create CSS transitions or animations that only play when the user hovers over them. Only set some HTML themes, and code the rest using your CSS skills.

How to make use of it:

Install & download.

# NPM
$ npm install onscroll-effect --save

Import the onscroll-effect.

import "onscroll-effect";

Include the ‘onscroll-effect.min.js’ script on the bottom of the webpage.

<script src="/dist/onscroll-effect.es6.min.js"></script>

Add the ‘data-scroll’ attribute to the target component.

<div data-scroll> 
  Element To Animate
</div>

By default, the library routinely adds the class ‘.is-outside’ to the component when it’s outside of the viewport.

.is-outside::before {
  transform: translateY(10em);
}

You’re allowed to make use of a customized CSS class as an alternative of  ‘.is-outside’.

<div data-scroll="your own class"> 
  Element To Animate
</div>

Determine whether or not to repeat the animation.

<div data-scroll="your own class"
     data-scroll-repeat="true"> 
     Element To Animate
</div>

<div data-scroll="your own class"
     data-scroll-repeat="5"> 
     Element To Animate
</div>

Set the gap from the top to trigger the animation.

<div data-scroll="your own class"
     data-scroll-repeat="true"
     data-scroll-offset="100"> 
     Element To Animate
</div>

Remove the CSS class as an alternative when the component is outside of the viewport. Defaults to ‘is-inside’.

<div data-scroll="your own class"
     data-scroll-repeat="true"
     data-scroll-offset="100"
     data-reverse="true"> 
     Element To Animate
</div>

animate div on scroll, on scroll animation, on scroll effect Plugin/Github


See Demo And Download

Official Website(Twikito): Click Here

This superior jQuery/javascript plugin is developed by Twikito. For extra Advanced Usages, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published.