Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

kudago/viewport-events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Viewport events Code Climate

Enable viewport events for HTML elements: enteredView, leftView.

Usage

$ npm install viewport-events

	var vpEvents = require('viewport-events');

	//enable viewport events for all elements on the page
	vpEvents.enable();
	$('.my-element').on('leftView', function(){});
	$('.my-other-element').on('enteredView', function(){});

	//Disable all viewport events
	vpEvents.disable();


	//Enable viewport events for a Node/NodeList
	vpEvents.enable(element);
	element.addEventListener('enteredView', function(){});
	element.addEventListener('leftView', function(){});

	//Disable viewport events for the previously added element/selector
	vpEvents.disable(element);

API

vp.enable(selector)

Enable viewport events for an Element, NodeList or selector. If no selector specified, '*' is used.

vp.disable(selector)

Disable viewport events for previously registered selector. If no selector specified, all viewport events are unbound.

vp.enteredViewCallbackName

Callback name used for entering viewport event. enteredView is used by default.

vp.leftViewCallbackName

Callback name used for leaving viewport event. leftView is used by default.

NPM

About

Viewport events for elements

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published