pavelbabenko / react-native-awesome-gallery

Performant, native-like, and well-customizable gallery for React Native.
MIT License
495 stars 54 forks source link

fix: moving images is incorrect #70

Closed rozhkovs closed 7 months ago

rozhkovs commented 7 months ago

Hi, Pavel!

Thank you for the wonderful library and for making a useful contribution to OpenSource!

We have integrated this library into our application, it works quite well, but there were some problems when viewing the image.

This is due to an incorrect size setting for the image. There are 2 cases:

  1. Undetermined order of calling the setImageDimensions function from useEffect and onLoad

We may have a situation where onLoad was called faster than useEffect when initializing the component. In this case, useEffect sets the width and height values to 0. This leads to a problem when the user cannot move the image when zooming in.

This is due to the library's `react-native-reanimated' feature.

In the JS stream, the values from the useSharedValue are updated asynchronously, for example:

const sharedValue = useSharedValue(0)
sharedValue.value = 1;
console.log(sharedValue.value) // 0
  1. Incorrect calculation of the size of the image relative to the container into which it is moved.

Example: A 200x300 picture on an iPhone 15. Gallery is displayed in full screen

https://github.com/pavelbabenko/react-native-awesome-gallery/assets/30261345/d873caa9-dc13-47c2-9bb2-62308b720a3a

If you have any questions, ask!)

rozhkovs commented 7 months ago

@pavelbabenko посмотри, пожалуйста.)

pavelbabenko commented 7 months ago

@rozhkovs Will check today, thanks!

pavelbabenko commented 7 months ago

@rozhkovs Released in 0.3.9. Good job!

rozhkovs commented 7 months ago

@pavelbabenko Thank you!