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

Allow for rubber band overscrolling on iOS #616

Merged
merged 1 commit into from
Mar 16, 2017
Merged
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
19 changes: 10 additions & 9 deletions source/Grid/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -1037,15 +1037,6 @@ export default class Grid extends PureComponent {
return
}

// On iOS, we can arrive at negative offsets by swiping past the start
// To prevent flicker here, we make playing in the negative offset zone cause nothing to happen.
if (event.target.scrollTop < 0) {
return
}

// Prevent pointer events from interrupting a smooth scroll
this._debounceScrollEnded()

// When this component is shrunk drastically, React dispatches a series of back-to-back scroll events,
// Gradually converging on a scrollTop that is within the bounds of the new, smaller height.
// This causes a series of rapid renders that is slow for long lists.
Expand All @@ -1057,6 +1048,16 @@ export default class Grid extends PureComponent {
const scrollLeft = Math.min(Math.max(0, totalColumnsWidth - width + scrollbarSize), event.target.scrollLeft)
const scrollTop = Math.min(Math.max(0, totalRowsHeight - height + scrollbarSize), event.target.scrollTop)

// On iOS, we can arrive at negative offsets by swiping past the start or past the end
// Luckily for us, scrollTop above already models these constraints
// So, if scrollTop !== event.target.scrollTop, then we're scrolling outside the constraints and don't need rerenders
if (event.target.scrollTop !== scrollTop) {
return
}

// Prevent pointer events from interrupting a smooth scroll
this._debounceScrollEnded()

// Certain devices (like Apple touchpad) rapid-fire duplicate events.
// Don't force a re-render if this is the case.
// The mouse may move faster then the animation frame does.
Expand Down