element-listener-js
v0.3.0
Published
Detect even more events on an HTMLElement
Downloads
5
Maintainers
Readme
Element Listener
A light-weight library that allows you to detect some extremely useful events on DOM Elements that have not otherwise been made available in the standard web events.
Usage
Detect when an element is scrolled in and out of view
You can detect when an element on a web page is scrolled in and out of the browser's viewport.
It supports scrolling in all directions (up, down, left, right) including offsets.
The following is a simple example, assuming you already have an element on your page with an id of my-element
...
var elementListener = new ElementListener({
el: document.getElementById('my-element'),
onEnterView: function () {
// element has been scrolled into view!
},
onExitView: function () {
// element has been scrolled out of view!
}
});