@jswork/next-element-in-viewport
v1.0.0
Published
Detect element if is in viewport.
Downloads
2
Readme
next-element-in-viewport
Detect element if is in viewport.
installation
npm install -S @jswork/next-element-in-viewport
usage
import '@jswork/next-element-in-viewport';
// scroll into view when element not in the viewport
const el = document.querySelector('.to-scroll-element');
if (el && !nx.elementInViewport(el)) {
el.scrollIntoView();
}
resources
- https://stackoverflow.com/questions/123999/how-can-i-tell-if-a-dom-element-is-visible-in-the-current-viewport
license
Code released under the MIT license.