Fix jitter when quickly swiping back and forth between pages (iOS) #254
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.
The problem: After a swipe is complete and the offset is being set in the state, if you keep swiping you can potentially have the ScrollView's internal offset be different than the one you are setting in state. If this is the case, then when the render happens and the offset is passed in as a prop to ScrollView, then it resets the offset to the one specified. The result is that you can be mid-swipe and the pages will jump back partially to the old offset causing some nasty jitter.
The fix: I added this.internals to store calculated values that are used a lot and are passed back to callbacks, but do not directly effect the render (isScrolling and offset). Offset does effect rendering but should only effect it when the size changes or if total pages changes. So offset is stored in this.internals most of the time and it's occasionally saved to the state to force the ScrollView to update. You will notice the callbacks that were getting this.state passed to them now get this.fullState() which includes state and internals.