Skip to content

Commit

Permalink
Allow for rubber band overscrolling on iOS
Browse files Browse the repository at this point in the history
Untested Resolution for follow up by @maxsalven on bvaughn#566
  • Loading branch information
toddtarsi authored Mar 16, 2017
1 parent 68a259a commit 8857680
Showing 1 changed file with 10 additions and 9 deletions.
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

0 comments on commit 8857680

Please sign in to comment.