HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/insiders/wp-load/wp-content/plugins/breadly/lib/inview/_scroll-direction.js
export const scrollUpClass = "gtm-scrolling-up";
export const scrollDownClass = "gtm-scrolling-down";

const scrollDirectionDetector = (e) => {
	if (window.pageYOffset >= prevOffset) {
		scrollingDown = true;
	} else {
		scrollingDown = false;
	}

	document.body.classList.toggle(scrollUpClass, !scrollingDown);
	document.body.classList.toggle(scrollDownClass, scrollingDown);

	prevOffset = window.pageYOffset;
};

/**
 * Self registration
 */

let prevOffset = null;
let scrollingDown = false;

if (prevOffset === null) {
	prevOffset = window.pageYOffset;

	window.addEventListener("scroll", scrollDirectionDetector, {
		passive: true,
		capture: true,
	});

	// Trigger for current inview items at page load
	window.addEventListener("DOMContentLoaded", scrollDirectionDetector);
}