mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: This diff updated `PointerEvents` enum to reduce duplication for null checks on pointer events string. Changelog: [Internal] Reviewed By: javache Differential Revision: D33717223 fbshipit-source-id: ff542a05240393416d85651ca08cd55136eb79a4
47 lines
1.4 KiB
Java
47 lines
1.4 KiB
Java
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
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.
|
|
*/
|
|
public enum PointerEvents {
|
|
|
|
/** Neither the container nor its children receive events. */
|
|
NONE,
|
|
|
|
/** Container doesn't get events but all of its children do. */
|
|
BOX_NONE,
|
|
|
|
/** Container gets events but none of its children do. */
|
|
BOX_ONLY,
|
|
|
|
/** Container and all of its children receive touch events (like pointerEvents is unspecified). */
|
|
AUTO,
|
|
;
|
|
|
|
public static PointerEvents parsePointerEvents(String pointerEventsStr) {
|
|
if (pointerEventsStr == null) {
|
|
return PointerEvents.AUTO;
|
|
} else {
|
|
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;
|
|
}
|
|
}
|