react-native-pinchable
react-native-pinchable copied to clipboard
onActive event needed to disable other gestures
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
I needed to know when pinching is active or not in order to disable all other gestures as the library is crashing iOS devices while pinching is active and other gestures are also active
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-pinchable/android/src/main/java/com/oblador/pinchable/PinchableView.java b/node_modules/react-native-pinchable/android/src/main/java/com/oblador/pinchable/PinchableView.java
index 9f22074..1419b50 100644
--- a/node_modules/react-native-pinchable/android/src/main/java/com/oblador/pinchable/PinchableView.java
+++ b/node_modules/react-native-pinchable/android/src/main/java/com/oblador/pinchable/PinchableView.java
@@ -18,6 +18,11 @@ import android.animation.ValueAnimator;
import android.view.animation.DecelerateInterpolator;
import com.facebook.react.views.view.ReactViewGroup;
+import com.facebook.react.uimanager.events.RCTEventEmitter;
+import com.facebook.react.bridge.WritableMap;
+import com.facebook.react.bridge.Arguments;
+
+import javax.annotation.Nullable;
public class PinchableView extends ReactViewGroup implements OnTouchListener {
private final int animationDuration = 400;
@@ -34,6 +39,8 @@ public class PinchableView extends ReactViewGroup implements OnTouchListener {
private ColorDrawable backdrop = null;
private BitmapDrawable clone = null;
+ private @Nullable RCTEventEmitter mEventEmitter;
+
public PinchableView(Context context) {
super(context);
this.setOnTouchListener(this);
@@ -122,6 +129,7 @@ public class PinchableView extends ReactViewGroup implements OnTouchListener {
}
active = true;
+ setOnActive(true);
if (backdrop == null) {
backdrop = new ColorDrawable(Color.BLACK);
@@ -195,6 +203,7 @@ public class PinchableView extends ReactViewGroup implements OnTouchListener {
clone = null;
}
setVisibility(View.VISIBLE);
+ setOnActive(false);
}
public void setMinimumZoomScale(float minimumZoomScale) {
@@ -204,4 +213,16 @@ public class PinchableView extends ReactViewGroup implements OnTouchListener {
public void setMaximumZoomScale(float maximumZoomScale) {
maxScale = maximumZoomScale;
}
+
+ public void setOnActive(boolean active) {
+ if (mEventEmitter != null) {
+ WritableMap params = Arguments.createMap();
+ params.putBoolean("value", active);
+ mEventEmitter.receiveEvent(getId(), "onAc
@felix-phil , was curios whether this fully works or there are some issues in this patch
I currently use it on a production project. onActive prop to know when the pinch is going on so as to deactivate all other animation gestures. So, it works.