intersect-events
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

intersect-events

'intersect-events' add intersection events to dom elements.

Install

npm i --save-dev intersect-events

Usage

import addIntersectEvents from 'intersect-events';

const el: HTMLElement = document.querySelector('#id');
const observer: IntersectionObserver = addIntersectEvents(el);

el.addEventListener('intersect', (e): void => {
  // do something
});
el.addEventListener('intersectEnter', (e): void => {
  // do something
});
el.addEventListener('intersectLeave', (e): void => {
  // do something
});

Syntax

const observer: IntersectionObserver = addIntersectEvents(el[, options]);

Events

el.addEventListener(intersectEvents, callback);

intersect : This event is fired at an Element when the percentage of the target element is visible crosses a threshold.

intersectEnter : This event is fired at an Element when the percentage of the target element is visible crosses a threshold and intersectionObserverEntry.isIntersectiong is true.

intersectLeave : This event is fired at an Element when the percentage of the target element is visible crosses a threshold and intersectionObserverEntry.isIntersectiong is false.

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i intersect-events

    Weekly Downloads

    0

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    4.84 kB

    Total Files

    6

    Last publish

    Collaborators

    • heishi1humanity