class-scroll

Scroll visible elements to add CSS

MIT License

Downloads
312
Stars
0

Preview

https://xjh22222228.github.io/class-scroll

Code demo

demo.js

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 Type
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
Package Rankings
Top 31.62% on Npmjs.org