那是我第一次在React Native中使用Pinch Gesture Handler ...我正在尝试使用Expo创建可缩放的相机。我在做什么:
const handlePinch = (nativeEvent) => {
const { scale, velocity } = nativeEvent;
let newZoom =
velocity > 0
? zoom + scale * velocity * (Platform.OS === "ios" ? 0.01 : 25)
: zoom -
scale * Math.abs(velocity) * (Platform.OS === "ios" ? 0.02 : 50);
if (newZoom < 0) newZoom = 0;
else if (newZoom > 0.5) newZoom = 0.5;
setZoom(newZoom);
};
...
<ExpoCamera
...
zoom={zoom}
...
>
工作但不太顺畅...有什么更好的方法吗?