Allow views to be collapsed when pointerEvents is set

Reviewed By: astreet

Differential Revision: D4440164

fbshipit-source-id: 88a710affea229228f9c96b82d0bcf4c81f3205d
This commit is contained in:
Pieter De Baets
2017-01-23 11:22:37 -08:00
committed by Facebook Github Bot
parent 29a996c83e
commit 88eeea0995
3 changed files with 16 additions and 4 deletions

View File

@@ -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;
}
}
}