pavelbabenko / react-native-awesome-gallery

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

Image snaps to horizontal center after scaling #13

Closed yfunk closed 3 years ago

yfunk commented 3 years ago

Description

When performing any gesture to change the image scale, the image seems to always center itself horizontally after the gesture has ended. This is fine when scaling the image to be smaller than the container (scale < 1), but should not be happening when zooming in (scale > 1).

Right now this causes the "focus" to shift away from the point that was zoomed into after ending the gesture. For me this issue is happening on Android using the package versions listed below, I was not yet able to test it on an iOS device.

https://user-images.githubusercontent.com/14955991/115701179-cf4fbb00-a367-11eb-938d-95cc112d5ba5.mp4

Minimal code example

export const ImageScreen = () => {
  const source = 'https://homepages.cae.wisc.edu/~ece533/images/cat.png';
  return <Gallery data={[source]} />;
}

Package versions

pavelbabenko commented 3 years ago

Fixed in https://github.com/Flair-Dev/react-native-awesome-gallery/releases/tag/v0.1.1

suraj-ingle commented 1 year ago

Facing a similar issue. The scaled image snaps back to the vertical centre.

react-native-awesome-gallery: 0.3.5

<Gallery
 loop={true}
        emptySpaceWidth={0}
        style={{
          top: -57,
          position: 'absolute',
        }}
        onIndexChange={index => {
          setCurrentPage(index)
        }}
        ref={galleryRef}
        data={[...links]}
        renderItem={({ item }) => {
          return (
            <Pressable key={item.docID}>
                <Image
                  ...
                />
            </Pressable>
          )
        }}
        keyExtractor={(_item, index) => `${index}`}
      />
krik-chry commented 4 months ago

@pavelbabenko Is this still an issue? I notice that when I zoom a lot it recenters the image, instead of staying in the place i stopped the gesture