A waypoint library to find your place in the DOM. Pointer.js is built on the experimental Intersection Observer API to determine if an element is visible in the viewport. Pointer.js is ready to use across all browsers and all devices.
Source | |
---|---|
npm | npm install pointer.js --save |
yarn | yarn add pointer.js |
unpkg | https://unpkg.com/pointer.js |
var waypoint = new Pointer({
element: document.querySelector('.js-waypoint'),
handler: function (entry) {
alert('The element is in view!')
}
})
options: A Javascript object containing Pointer options. This object is required. It must contain element and handler properties.
options.element: A document element that you wish to set as the waypoint.
options.handler: A function that executes when the options.element is in view. The function passes an [Intersection Observer Entry] (https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry).
Copyright 2018 Anthony Gonzales. Code released under the MIT License.