zoom issue #5533
AmitGunjan
started this conversation in
Ideas
zoom issue
#5533
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
On Zoom view is getting hide behind the below view, is there is any way to overlap with top and bottom view after zoom.
Below are the code for pinch zoom
import React, { useRef, useState } from 'react';
import { Animated, Platform } from 'react-native';
import { PanGestureHandler, PinchGestureHandler, State } from 'react-native-gesture-handler';
const PinchZoom = ({ children }) => {
const baseScale = useRef(new Animated.Value(1)).current;
const pinchScale = useRef(new Animated.Value(1)).current;
const lastScale = useRef(1);
const pan = useRef(new Animated.ValueXY()).current;
const [enablePan, setEnablePan] = useState(false);
const onPinchGestureEvent = Animated.event(
[{ nativeEvent: { scale: pinchScale } }],
{ useNativeDriver: true }
);
const onPinchHandlerStateChange = ({ nativeEvent }) => {
if (nativeEvent.oldState === State.ACTIVE) {
pinchScale.setValue(1);
if(nativeEvent.scale > 1){
lastScale.current *= nativeEvent.scale;
}
else{
lastScale.current = 1;
}
baseScale.setValue(lastScale.current);
};
const onPanGestureEvent = Animated.event(
[
{
nativeEvent: {
translationX: pan.x,
translationY: pan.y,
},
},
],
{ useNativeDriver: true }
);
const onPanHandlerStateChange = ({ nativeEvent }) => {
if (enablePan && nativeEvent.oldState === State.ACTIVE) {
pan.setOffset({
x: pan.x._value,
y: pan.y._value,
});
pan.setValue({ x: 0, y: 0 });
}
};
const containerStyle = {
flex: 1,
...Platform.select({
ios: {
// shadowColor: 'black',
// shadowOpacity: 0.5,
// shadowRadius: 5,
},
android: {
elevation: enablePan ? 1 : 0,
},
}),
};
return (
<PinchGestureHandler
);
};
export default PinchZoom;
Beta Was this translation helpful? Give feedback.
All reactions