Fix jitter when quickly swiping back and forth between pages (iOS)#254
Merged
leecade merged 4 commits intoleecade:masterfrom Oct 8, 2016
Merged
Fix jitter when quickly swiping back and forth between pages (iOS)#254leecade merged 4 commits intoleecade:masterfrom
leecade merged 4 commits intoleecade:masterfrom
Conversation
Owner
|
very nice. Some issues mentioned the problem before. |
leecade
added a commit
that referenced
this pull request
Oct 8, 2016
Owner
|
Hi @nemophrost I found a problem in this PR. Breaking the consistent scroll animate direction in loop mode. Reproduce:
if press the right button, run a loop: but now we see the wrong animation when Please check again and help me fix it. |
Contributor
Author
|
@leecade oh yeah, that makes sense. I'll fix that with a new PR |
Owner
|
@nemophrost great 👍 |
Contributor
Author
Contributor
|
Nice. I think this fixes issue I've been using a workaround for in #172? |
|
每次循环结束后会闪屏一下 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.