Glazzes / react-native-zoom-toolkit

Zoom anything you want! Most complete pinch to zoom utilities for React Native
https://glazzes.github.io/react-native-zoom-toolkit/
MIT License
192 stars 11 forks source link

[Gallery] onZoomBegin callback? #37

Closed cw-nikhilnaik closed 3 months ago

cw-nikhilnaik commented 4 months ago

Hello,

It would be really helpful if we can have onZoomBegin and onZoomEnd callback so that we can add animations to other components.

Currently we can only requestState and fetch scale value but thats a ref, so cant detect it

Also there is onPinchStart and no onDoubleTap which again doesnt serve my need

My need: I want to detect when the image has been zoomed and when it is in initial state automatically

Glazzes commented 4 months ago

I'm sorry but you'll have to ellaborate your statements better, the only thing I got was that you need onDoubleTap callback.

It would be really helpful if we can have onZoomBegin and onZoomEnd callback so that we can add animations to other components.

Any example of such animations? What are the expected contents of onZoomBeing and onZoomEnd arguments?

Currently we can only requestState and fetch scale value but thats a ref, so cant detect it

What do you mean by "can't detect it"? What's wrong with the ref?

cw-nikhilnaik commented 4 months ago

Hi, thankyou for the reply

So I have a screen where i render the gallery. I have also few touchable buttons with position "absolute" just below the image with zIndex:1 so that I can click on the button, but if I zoom the image, the button stays on top of image since zIndex:1, so I want the zIndex:0 when image is zoomed. Hence I needed onZoomBegin callback to know when the image started getting zoomed, and onZoomEnd callback to know when the image is back to original state.

With ref, it doesnt trigger an update, so can't use a useEffect to know the state.

I have a temporary solution implemented to workaround over it

useEffect(() => { setTimeout(()=>{ isZoomed = ref.current?.requestState().scale > 1 },100) },[])

But this is temporary fix

Glazzes commented 3 months ago

Callbacks added on pr #38