You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Elements we want to trackvaritems=document.querySelectorAll('div')varScrollPosition=require('scroll-position')varitemPosition=ScrollPosition(items,{// Default settingsoffsetOut: 100,// y position in px where items leave the viewportoffsetIn: 0// y position where items enter the viewport})itemPosition.on('out',function(el){// el was scrolled out of the top of the viewportconsole.log(el)})itemPosition.on('in',function(el){// el was scrolled in from the top of the viewportconsole.log(el)})itemPosition.on('inOut',function(el){// el was scrolled in or out of the top of the viewportconsole.log(el)})
Fired whenever one of the supplied items is scrolled out the top of the viewport
e.g scrolling down, and the item goes out the top of the viewport.
The first argument to the callback is the element which scrolled out.
in
Fired whenever one of the supplied items is scrolled into the top of the viewport
e.g scrolling up, and the item enters the top of the viewport.
The first argument to the callback is the element whom scrolled in.
inOut
Fired whenever one of the target items scrolls in OR out of the top of the viewport.
e.g scrolling up or down, and the item enters or leaves the top of the window.
The first argument to the callback is the element which scrolled in or out.