Coffeekraken.io 0.0.1

InViewportStatusChangeDetector

This class allows you to monitor an HTMLElement and be notified when it enters or exit the viewport.

Example

    const detector = new InViewportStatusChangeDetector(myCoolHTMLElement);
detector.on('enter', (elm) => {
        // the element has entered the viewport
});
detector.on('exit', (elm) => {
        // the element has exit the viewport
});

Author : Olivier Bossel olivier.bossel@gmail.com

Constructor

Name Type Description Status Default
elm { HTMLElement } The element to track required

Methods

on

Add a callback

Name Type Description Status Default
status { String } The status to track (enter exit) required
cb { Function } The callback to add required

Return { InViewportStatusChangeDetector } The instance itself to maintain chainability

off

Remove a callback

Name Type Description Status Default
status { String } The status to remove (enter exit) required
cb { Function } The callback to remove required

Return { InViewportStatusChangeDetector } The instance itself to maintain chainability

destroy

Destroy the tracker