Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const domScrollableArea = scrollableArea ? document.querySelector(scrollableArea) : undefined;
const height = domScrollableArea
? domScrollableArea.offsetHeight + domScrollableArea.getBoundingClientRect().top
: window.innerHeight;
const width = scrollableArea
? domScrollableArea.offsetWidth + domScrollableArea.getBoundingClientRect().left
: window.innerWidth;
const boundingClientRect = element.getBoundingClientRect();
if (boundingClientRect) {
const viewportEntered = element.getAttribute('data-in-viewport-entered');
triggerDidEnterViewport(
element,
isInViewport(
boundingClientRect,
height,
width,
viewportTolerance
),
viewportSpy,
enterCallback,
exitCallback,
viewportEntered
);
if (viewportSpy || viewportEntered !== 'true') {
// recursive
// add to pool of requestAnimationFrame listeners and executed on set schedule
addRAF(
startRAF.bind(
isInViewport(...args) {
return isInViewport(...args);
}