locate=$(document).height()-$(window).height() times=0 scroller = (cb)-> if locate<=$(document).height()-$(window).height() times=0 locate+=100 scroll(0,locate) clearTimeout(timer) timer=setTimeout("scroller()",54) timer else await sleep 3000, defer() times++ console.log times return if times>3 scroller() scroller()