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

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

Merged
merged 4 commits into from
Oct 8, 2016

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.

@leecade
Copy link
Owner

leecade commented Oct 8, 2016

very nice. Some issues mentioned the problem before.

@leecade leecade merged commit 1bbec4c into leecade:master Oct 8, 2016
@leecade
Copy link
Owner

leecade commented Oct 8, 2016

Hi @nemophrost

I found a problem in this PR. Breaking the consistent scroll animate direction in loop mode.

Reproduce:

loop=true

if press the right button, run a loop: 1->2->3->1

but now we see the wrong animation when 3->1.

Please check again and help me fix it.

@nemophrost
Copy link
Contributor Author

@leecade oh yeah, that makes sense. I'll fix that with a new PR

@leecade
Copy link
Owner

leecade commented Oct 9, 2016

@nemophrost great 👍

@nemophrost
Copy link
Contributor Author

nemophrost commented Oct 11, 2016

@leecade #260 fixes it. Not the most elegant solution, but after several house of trying lots of other things, it at least works consistently. I'm open to better ideas for sure :)

@fungilation
Copy link
Contributor

Nice. I think this fixes issue I've been using a workaround for in #172?

@Quenton2018
Copy link

每次循环结束后会闪屏一下

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.

4 participants