Add pointerEvents prop to RN Android scroll views

Summary:
Per discussion in the previous diff D33672110, it's ok to add the `pointerEvents` prop to scrollview. This will help prevent scrolling on the ScrollView if pointerEvents is set to `box-none`, or `none`.

Corresponding doc changes are in https://github.com/facebook/react-native-website/pull/2936

Changelog:
[Android][Added] - Add new API in ScrollView and HorizontalScrollView to process pointerEvents prop.

Reviewed By: javache

Differential Revision: D33699223

fbshipit-source-id: 1cae5113e9e7d988fc4c4765c41d817a321804c4
This commit is contained in:
Xin Chen authored and Facebook GitHub Bot committed 2022-01-21 13:40:09 -08:00
1 parent d0f0234656
commit 48f6967ae8
5 files changed
+74

No files matched your search

@@ -7,6 +7,8 @@
package com.facebook.react.uimanager;
import java.util.Locale;
/**
* Possible values for pointer events that a view and its descendants should receive. See
* https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events for more info.
@@ -25,4 +27,16 @@ public enum PointerEvents {
/** Container and all of its children receive touch events (like pointerEvents is unspecified). */
AUTO,
;
public static PointerEvents parsePointerEvents(String pointerEventsStr) {
return PointerEvents.valueOf(pointerEventsStr.toUpperCase(Locale.US).replace("-", "_"));
}
public static boolean canBeTouchTarget(PointerEvents pointerEvents) {
return pointerEvents == AUTO || pointerEvents == PointerEvents.BOX_ONLY;
}
public static boolean canChildrenBeTouchTarget(PointerEvents pointerEvents) {
return pointerEvents == PointerEvents.AUTO || pointerEvents == PointerEvents.BOX_NONE;
}
}