Skip to content

Instantly share code, notes, and snippets.

@jbmyid
Created August 5, 2015 10:41
Show Gist options
  • Save jbmyid/aaf414a775ad19ce5f77 to your computer and use it in GitHub Desktop.
Save jbmyid/aaf414a775ad19ce5f77 to your computer and use it in GitHub Desktop.
window.infyScroll = (el_id, url)->
self = @
@finish = false
@complete = ->
self.inProgress = false
self.nextPage++
@xmlhttp = new sendAjaxRequest("", url, "GET", @complete)
@nextPage = 2
@inProgress = false
@ele = document.getElementById(el_id)
@ele.addEventListener "scroll", ->
if !finish && !self.inProgress && (self.ele.scrollHeight - (self.ele.scrollTop+self.ele.clientHeight)) < 10
self.inProgress = true
self.xmlhttp.send "page="+ self.nextPage
@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment