Track the visibility of dom elements and fire user defined callbacks as they appear and disappear.
Be sure to view the documentation on the project page
Include appear.js in your page, it has no dependencies.
appear() passing in an object with the following:
initfunction to run when dom is interactive, but before appear.js has started tracking.
elementsrequired function that returns an htmlcollection of elements to track. The dom will be interactive at this point. Can alternatively be an existing htmlcollection instead of a function.
appearfunction to run when an element is in view, passed the element that has come into view. If defined then appear.js will track elements until they come into view.
disappearfunction to run when an element goes out of view, passed the element that has gone out of view. If defined then appear.js will track elements until they go out of view.
reappearif true appear.js will keep tracking elements for successfuive appears and dissappears. Default is false.
boundsincrease, in pixels, to the threshold size of the element so it can be "viewable" before it is actually in the viewport.
debounceappear.js tracks elements on browser scroll and resize, for performance reasons this check is "debounced" to only happen once for multiple events, 50ms after the last event ends. You can override this value here.
deltaSpeedin addition to debouncing, appear.js will also check for items during continuous slow scrolling, you can controll how slow the scrolling should be via this value. Default is 50 (pixels).
deltaTimeoutafter a succesful delta speed check, appear.js will not check for viewable items again until this timeout passes. Default is 500 (ms).
donefunction called when appear.js is no longer tracking any items and event listeners have been removed.
appear() will return an object with the following:
trigger()force a check for viewable elements.
pause()temporarily stop tracking elements.
resume()resume tracking elements.
destroy()permanently stop tracking elements.