src/main/javascript/scroll/floatz.scroll.scroller.js
/**
 * Register handler that is necessary for scroll start / end events.
 *
 * @param {Scroller} scroller Scroller
 * @see https://gomakethings.com/detecting-when-a-visitor-has-stopped-scrolling-with-vanilla-javascript/
 * @private
 */
Register handler that is necessary for scroll start / end events.
Register handler that is necessary for scroll start / end events .
function _registerScrollStartEndHandler(scroller) {
	if (scroller._scrollEndHandlers.length === 0 && scroller._scrollStartHandlers.length === 0) {
		let endScrollTimeout = null;
		DOM.addEvent(scroller._container, EVENT_SCROLL, () => {
			if(! scroller.isScrollToAction()) {
				if (endScrollTimeout === null) {
					_runScrollStartHandlers(scroller);
				}
				window.clearTimeout(endScrollTimeout);
				endScrollTimeout = setTimeout(() => {
					_runScrollEndHandlers(scroller);
					endScrollTimeout = null;
				}, 100); 
			}
		});
	}
}
function _registerScrollStartEndHandler ( scroller ) { if ( scroller . _scrollEndHandlers . length === 0 && scroller . _scrollStartHandlers . length === 0 ) { let endScrollTimeout = null ; DOM . addEvent ( scroller . _container , EVENT_SCROLL , ( ) => { if ( ! scroller . isScrollToAction ( ) ) { if ( endScrollTimeout === null ) { _runScrollStartHandlers ( scroller ) ; } window . clearTimeout ( endScrollTimeout ) ; endScrollTimeout = setTimeout ( ( ) => { _runScrollEndHandlers ( scroller ) ; endScrollTimeout = null ; } , 100 ) ; } } ) ; } }
Register handler that is necessary for scroll start / end events.
Register handler that is necessary for scroll start / end events .
// console.log("EVENT_SCROLL"); // Handle start/end handlers for manual scrolling only // Run scroll start handlers // Extend timeout for scroll end handlers throughout the scroll // Run scroll end handlers // Scrolling on iOS needs more time otherwise flickers!