detect when scrolling stops

Solutions on MaxInterview for detect when scrolling stops by the best coders in the world

showing results for - "detect when scrolling stops"
Callen
08 Jan 2019
1// Setup isScrolling variable
2var isScrolling;
3
4// Listen for scroll events
5window.addEventListener('scroll', function ( event ) {
6
7	// Clear our timeout throughout the scroll
8	window.clearTimeout( isScrolling );
9
10	// Set a timeout to run after scrolling ends
11	isScrolling = setTimeout(function() {
12
13		// Run the callback
14		console.log( 'Scrolling has stopped.' );
15
16	}, 66);
17
18}, false);
19