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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.10latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.10
1.0.00

Package Sidebar

Install

npm i lagden-trigger-viewport

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • lagden