-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Improving detection of scroll ended #742
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c20bf15
Using requestAnimationFrame instead of setTimeout to ensure that the …
gnbaron d534319
Fixing tests after start to using requestAnimationFrame and cancelAni…
gnbaron aa4bcfd
Using requestAnimationFrame instead of setTimeout to ensure that the …
gnbaron a706712
Fixing tests after start to using requestAnimationFrame and cancelAni…
gnbaron 14678f8
Merge branch 'master' of https://github.com/guilhermefloriani/react-v…
gnbaron 089af39
Avoid use a chain lookup
gnbaron 3264b83
Avoid allocating one function for each scroll ended callback.
gnbaron c47959f
merge
gnbaron d782956
Use cancelAnimationFrame instead of clearTimeOut on componentWillUnmo…
gnbaron a67e150
Merge branch 'master' of https://github.com/bvaughn/react-virtualized
gnbaron 477ac94
Encapsulates scroll end debouncing into a timeout function relying on…
jaredLunde cf2f8d0
Fixing pretty warnings and use just named imports for requestAnimatio…
gnbaron c2e1d93
Merge branch 'master' of https://github.com/bvaughn/react-virtualized
gnbaron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ export default class Masonry extends PureComponent { | |
); | ||
this._setScrollingContainerRef = this._setScrollingContainerRef.bind(this); | ||
this._onScroll = this._onScroll.bind(this); | ||
this._delayScrollEnded = this._delayScrollEnded.bind(this); | ||
} | ||
|
||
clearCellPositions() { | ||
|
@@ -290,16 +291,28 @@ export default class Masonry extends PureComponent { | |
} | ||
} | ||
|
||
_debounceResetIsScrolling() { | ||
/** | ||
* Check if the difference between current time and the last scroll ended event is greater. | ||
* than the scrollingResetTimeInterval prop, else schedule this function to execute again. | ||
*/ | ||
_delayScrollEnded() { | ||
const { scrollingResetTimeInterval } = this.props; | ||
if (Date.now() - this._scrollDebounceStart >= scrollingResetTimeInterval) { | ||
this._debounceScrollEndedCallback(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto as for |
||
} else { | ||
this._disablePointerEventsTimeoutId = window.requestAnimationFrame( | ||
this._delayScrollEnded | ||
); | ||
} | ||
} | ||
|
||
_debounceResetIsScrolling() { | ||
if (this._debounceResetIsScrollingId) { | ||
clearTimeout(this._debounceResetIsScrollingId); | ||
window.cancelAnimationFrame(this._debounceResetIsScrollingId); | ||
} | ||
|
||
this._debounceResetIsScrollingId = setTimeout( | ||
this._debounceResetIsScrollingCallback, | ||
scrollingResetTimeInterval | ||
this._scrollDebounceStart = Date.now(); | ||
this._debounceResetIsScrollingId = window.requestAnimationFrame( | ||
this._delayScrollEnded | ||
); | ||
} | ||
|
||
|
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
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.
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.
minor nit: I realize we weren't doing this before, and it's no big deal, but we might as well clear
this._disablePointerEventsTimeoutId
here.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.
Yes, I agree that the pointer must be cleared, but this hasn't been doing on
_debounceScrollEndedCallback
function?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.
You're right 😄 Sorry, I was just skimming the diff and that callback wasn't visible. Sorry~ 👍