coffeescript写的一个无限下拉小程序

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()

 

posted @ 2018-08-08 13:56  selola  阅读(170)  评论(0)    收藏  举报