Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable/disable scrolling option #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
18 changes: 10 additions & 8 deletions app/assets/javascripts/jquery.infinite-pages.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Released under the MIT License
state:
paused: false
loading: false
scrolling: true # autoload next page

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line ends with trailing whitespace


# Constructs the new InfinitePages object
#
Expand All @@ -41,14 +42,15 @@ Released under the MIT License
init: ->

# Debounce scroll event to improve performance
scrollTimeout = null
scrollHandler = (=> @check())
if @options.scrolling
scrollTimeout = null
scrollHandler = (=> @check())

@$context.scroll ->
if scrollTimeout
clearTimeout(scrollTimeout)
scrollTimeout = null
scrollTimeout = setTimeout(scrollHandler, 250)
@$context.scroll ->
if scrollTimeout
clearTimeout(scrollTimeout)
scrollTimeout = null
scrollTimeout = setTimeout(scrollHandler, 250)

# Internal helper for logging messages
_log: (msg) ->
Expand Down Expand Up @@ -79,7 +81,7 @@ Released under the MIT License
@_log "Loaded all pages"
else
@_loading()

@_log 'Load from url: ', @$container.find(@options.navSelector).attr 'href'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line exceeds maximum allowed length

$.getScript(@$container.find(@options.navSelector).attr('href'))
.done(=> @_success())
.fail(=> @_error())
Expand Down