1.0.13 • Published 4 years ago

lb-onvisible v1.0.13

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

lb-onvisible

Adds classNames to the elements when they are visible.
If the IntersectionObserver API is not supported, the classeNames will be added on page load.
Great for animation libraries like Animate.css.

Usage

1. Javascript trigger

import { onVisible } from "lb-onvisible"
const options = {
	class: "oneClass anotherClass ...",
	duration: 700,
	delay: 0, 
	reverse: false,
	root: viewport
}
onVisible( '.selector', options );

//also accepts Node and NodeList instead of a Selector

2. HTML trigger

import  "lb-onvisible"
<div data-onVisible="fadeFromLeft">
	will fade in from the left when intersecting with the root element
</div>

NOTE :
Elements all have .offScreen { opacity: 0; } before the class is applied.
Feel free to override.

Options

  • class : no default : string => class to add when the element is on screen
  • duration : 700 : number => sets "animation-duration" for the element
  • delay : 0 : number => delay to set className between each element.
  • reverse : false : boolean => reverse the order when delay is applied
  • root : viewport : DOM element => the IntersectionObserver root.

Built-in classes

  • fadeFromTop
  • fadeFromBottom
  • fadeFromLeft
  • fadeFromRight
1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago