1.0.1 • Published 8 years ago
lagden-trigger-viewport v1.0.1
TriggerViewport
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