Skip to content

Commit

Permalink
Unbind scroll event when reinstantiated
Browse files Browse the repository at this point in the history
Scroll trigger would only take effect on first load: navigating back to
the same page would fail to auto-load the next page on scroll.

Solution from: magoosh#24
  • Loading branch information
bendilley committed Sep 21, 2021
1 parent 6a63eac commit 63941ec
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/assets/javascripts/jquery.infinite-pages.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ Released under the MIT License
# Have we waited enough time since the last check?
shouldCheck = -> +new Date > lastCheckAt + scrollDelay

console.log "Unbinding..."
@$context.unbind('scroll')
@$context.scroll ->
scrollHandler() if shouldCheck() # Call check once every scrollDelay ms
if scrollTimeout
Expand Down

0 comments on commit 63941ec

Please sign in to comment.