Newton's Principia Mathematica

    lagden-trigger-viewport

    1.0.1 • Public • Published

    TriggerViewport

    NPM version Build Status Coverage Status Dependency Status devDependency Status XO code style

    Detects when an element reaches the value inside the viewport

    Install

    $ npm i -S lagden-trigger-viewport
    

    Usage

    const d = document.querySelectorAll('.man')
    let p = new TriggerViewport(d, {
        trigger: 75,
        cb(el, allFired) {
            el.classList.add('man--jump')
            if (allFired) {
                p = null
            }
        }
    })

    API

    TriggerViewport

    constructor(els, options = {})

    Name Type Required Default Description
    els array yes Array of HTML Elements
    options object no see below Some options
    options
    Name Type Required Default Description
    trigger int no 50 0 is top and 100 is bottom (percentage)
    cb function no null Callback

    License

    MIT © Thiago Lagden

    Install

    npm i lagden-trigger-viewport

    DownloadsWeekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • lagden