Skip to content

Fix jitter when quickly swiping back and forth between pages (iOS)#260

Merged
leecade merged 3 commits intoleecade:masterfrom
nemophrost:fast-swipe-fix
Oct 17, 2016
Merged

Fix jitter when quickly swiping back and forth between pages (iOS)#260
leecade merged 3 commits intoleecade:masterfrom
nemophrost:fast-swipe-fix

Conversation

@nemophrost
Copy link
Contributor

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.

Also includes some extra linting.

@leecade
Copy link
Owner

leecade commented Oct 17, 2016

Great PR. I tested on iOS and works fine. Many issues will be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants