We can solve this problem by Adding delay to window scroll event. If user is not scrolling for last one second, then We can confirm that the user stopped scrolling.
Script
In this below script window was bonded to scroll event
Scroll event will be triggered after 1 second ( 1000 milli seconds)
export class AppComponent { _timeout: any = null; constructor() { this._timeout = null; window.onscroll = () => { if(this._timeout){ //if there is already a timeout in process cancel it window.clearTimeout(this._timeout); } this._timeout = setTimeout(() => { this._timeout = null; alert('scroll stopped'); },1000); }; } }
0 comments:
Post a Comment