Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 1.02 KB

whenInViewport.md

File metadata and controls

22 lines (16 loc) · 1.02 KB

whenInViewport

Monitor an HTMLElement to be notified when it is in the viewport

Parameters

Name Type Description Status Default
elm { HTMLElement } The element to monitor required
offset { Number } An offset that represent the distance before entering the viewport for the detection optional 50

Return { (Promise) } The promise that will be resolved when the element is in the viewport

Example

	import whenInViewport from 'coffeekraken-sugar/js/dom/whenInViewport'
whenInViewport(myCoolHTMLElement).then((elm) => {
		// do something with your element that has entered the viewport...
});

Author : Olivier Bossel [email protected] https://olivierbossel.com