-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add support for turbolinks; Allow periodic checks while scrolling #15
Open
cesmoak
wants to merge
7
commits into
magoosh:master
Choose a base branch
from
cesmoak:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change does two main things: - element references are recached after next-page results are loaded - any requests initiated before a turbolinks pageload are ignored if they complete after the results are loaded The element reference to the container element is made by attaching a unique data attribute to it: “data-jquery-infinite-pages-container” and setting the value to a unique id for the instance of InfinitePages. Requests are ignored by keeping a queue of timestamps marking when they begin and keeping a timestamp of the last time turbolinks changed the page, invalidating all before that last page-load.
The previous implementation would wait until scrolling stopped to check and potentially load the next page results. This change allows for checks to occur (periodically, at the scrollDelay frequency) so that results can be loaded while scrolling is still happening.
We need to actually call shouldCheck.
scrollTimeout = setTimeout(scrollHandler, 250) | ||
scrollTimeout = setTimeout(scrollHandler, scrollDelay) | ||
|
||
# Set a data attribute so we can find again after a turbolink page is loaded |
There was a problem hiding this comment.
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
In the previous version, the old $container element could still be referenced once a page load occurred. This fixes that problem by passing the old $container element reference to the post-load methods, ensuring a newer reference to the container is not incorrectly updated.
# Debounce scroll event to improve performance | ||
scrollTimeout = null | ||
scrollHandler = (=> @check()) | ||
# Set a data attribute so we can find again after a turbolink page is loaded |
There was a problem hiding this comment.
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
👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For turbolinks, this does two main things:
For periodic checks while scrolling: the previous implementation would wait until scrolling stopped to check and potentially load the next page results. This change allows for checks to occur (periodically, at the scrollDelay frequency) so that results can be loaded while scrolling is still happening.