class-scroll
v0.0.8
Published
Scroll visible elements to add CSS
Downloads
5
Readme
Demo
Install
npm install class-scroll
# or
yarn add class-scroll
# or
pnpm add class-scroll
Usage
import ClassScroll from 'class-scroll'
const classScroll = new ClassScroll([
el: '#app',
className: 'animate__animated animate__fadeIn',
threshold: 0.5,
delay: 0,
]).init()
Config
| Fields | Descriptions | 类型 |
| ---------- | --------------------------------------------------------------------------------------------------- | ----------------- | -------- | ---- |
| el | required
Node or selector | Element / String |
| className | required
The class that needs to be added when the element is visible | String |
| delay | Delay adding class | Number |
| threshold | threshold | Number / Number[] |
| root | root | Element | Document | null |
| rootMargin | rootmargin | Element | String |
| onVisible | Callback method when element is visible | Function |
| onHidden | Callback method when element is not visible | Function |