Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Made scrolling smooth on Android when parent updates index prop during pan #399

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hsource
Copy link

@hsource hsource commented May 14, 2020

Motivation

When a user releases a photo while panning on Android, the next image isn't smoothly animated in.

Cause/debugging

  1. Prerequisite: Use ImageViewer in a controlled way - update the index prop from within the onChange handler of the parent component
  2. The user releases a pan and this starts an animation in goNext or goPrevious, which also calls the onChange handler
  3. In the parent's onChange callback, the parent updates the index. this causes componentDidUpdate to call jumpToCurrentImage
  4. Even though we're already animating to the right image, jumpToCurrentImage calls setValue, which immediately cancels the animation

Fix

Make jumpToCurrentImage not call setValue if it's already animating to the right place

Testing

In a test app on Android:

Before After
Android before pan Android pan after

@hsource
Copy link
Author

hsource commented Aug 17, 2020

@ArtemKolichenkov, @ascoders - could you take a look? We'd love to merge this and stop using our own fork of this repository

sontaemoo pushed a commit to sontaemoo/react-native-image-viewer that referenced this pull request Jun 24, 2021
This was referenced Jun 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant