lazytrigger
Notify when certain points of the DOM enter / leave the view using on-intersect.
Installation
npm i --save lazytrigger
Example
var html = var LazyTrigger = var trigger = onEnter onLeave module { return html` Scroll down, check the console... Even more... `} { console} { console}
Why?
Put it to the bottom of an endless scrolling list, play sounds, change the background image, autoplay videos, you name it.
API
trigger = new LazyTrigger(onEnter(id), onLeave(id))
Initialize a new handler. onEnter
is called when a breakpoint enters the view, onLeave
is called when a breakpoint leaves the view; both get the id
of the breakpoint.
trigger.breakpoint(id)
Returns an empty element that will be observed. It has a comment inside (<!-- lazytrigger {id} -->
) in order to be easily identifiable.
trigger.stop(id)
Stop observing a specific breakpoint.
trigger.stopAll()
Stop observing all the breakpoints.