1.0.1 • Published 8 years ago

lagden-trigger-viewport v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

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 = {})

NameTypeRequiredDefaultDescription
elsarrayyesArray of HTML Elements
optionsobjectnosee belowSome options
options
NameTypeRequiredDefaultDescription
triggerintno500 is top and 100 is bottom (percentage)
cbfunctionnonullCallback

License

MIT © Thiago Lagden