Skip to content

antgonzales/pointer.js

Repository files navigation

pointer.js

Travis CI Build JavaScript Style Guide

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.

Installation

Source
npm npm install pointer.js --save
yarn yarn add pointer.js
unpkg https://unpkg.com/pointer.js

Usage

var waypoint = new Pointer({
  element: document.querySelector('.js-waypoint'),
  handler: function (entry) {
    alert('The element is in view!')
  }
})

API

new Pointer(options)

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 & Licensing

Copyright 2018 Anthony Gonzales. Code released under the MIT License.

About

☝️ A waypoint library to find your place in the DOM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published