mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-03 22:48:25 +08:00
Allow views to be collapsed when pointerEvents is set
Reviewed By: astreet Differential Revision: D4440164 fbshipit-source-id: 88a710affea229228f9c96b82d0bcf4c81f3205d
This commit is contained in:
committed by
Facebook Github Bot
parent
29a996c83e
commit
88eeea0995
@@ -446,7 +446,7 @@ public class NativeViewHierarchyOptimizer {
|
||||
|
||||
ReadableMapKeySetIterator keyIterator = props.mBackingMap.keySetIterator();
|
||||
while (keyIterator.hasNextKey()) {
|
||||
if (!ViewProps.isLayoutOnly(keyIterator.nextKey())) {
|
||||
if (!ViewProps.isLayoutOnly(props.mBackingMap, keyIterator.nextKey())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ package com.facebook.react.uimanager;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
|
||||
/**
|
||||
* Keys for props that need to be shared across multiple classes.
|
||||
*/
|
||||
@@ -64,6 +66,9 @@ public class ViewProps {
|
||||
|
||||
public static final String ASPECT_RATIO = "aspectRatio";
|
||||
|
||||
// Props that sometimes may prevent us from collapsing views
|
||||
public static final String POINTER_EVENTS = "pointerEvents";
|
||||
|
||||
// Props that affect more than just layout
|
||||
public static final String ENABLED = "enabled";
|
||||
public static final String BACKGROUND_COLOR = "backgroundColor";
|
||||
@@ -151,7 +156,14 @@ public class ViewProps {
|
||||
PADDING_TOP,
|
||||
PADDING_BOTTOM));
|
||||
|
||||
public static boolean isLayoutOnly(String prop) {
|
||||
return LAYOUT_ONLY_PROPS.contains(prop);
|
||||
public static boolean isLayoutOnly(ReadableMap map, String prop) {
|
||||
if (LAYOUT_ONLY_PROPS.contains(prop)) {
|
||||
return true;
|
||||
} else if (POINTER_EVENTS.equals(prop)) {
|
||||
String value = map.getString(prop);
|
||||
return "auto".equals(value) || "box-none".equals(value);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ReactViewManager extends ViewGroupManager<ReactViewGroup> {
|
||||
}
|
||||
}
|
||||
|
||||
@ReactProp(name = "pointerEvents")
|
||||
@ReactProp(name = ViewProps.POINTER_EVENTS)
|
||||
public void setPointerEvents(ReactViewGroup view, @Nullable String pointerEventsStr) {
|
||||
if (pointerEventsStr != null) {
|
||||
PointerEvents pointerEvents =
|
||||
|
||||
Reference in New Issue
Block a user