Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/assets/javascripts/jquery.infinite-pages.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Released under the MIT License
scrollTimeout = null
scrollHandler = (=> @check())

@$context.scroll ->
# Use namespace to let us unbind event handler
@$context.on 'scroll.infinitePages', ->
if scrollTimeout
clearTimeout(scrollTimeout)
scrollTimeout = null
Expand Down Expand Up @@ -113,6 +114,11 @@ Released under the MIT License
@_log "Scroll checks resumed"
@check()

# Stop event handling
stop: ->
@$context.off 'scroll.infinitePages'
@_log "Scroll checks stopped"

# Define the plugin
$.fn.extend infinitePages: (option, args...) ->
@each ->
Expand All @@ -122,6 +128,10 @@ Released under the MIT License
if !data
$this.data 'infinitepages', (data = new InfinitePages(this, option))
if typeof option == 'string'
data[option].apply(data, args)
if option == 'destroy'
data.stop args
$this.removeData 'infinitepages'
else
data[option].apply(data, args)

) window.jQuery, window