Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ void RNGestureHandlerDetectorShadowNode::layout(LayoutContext layoutContext) {
// TODO: consider allowing more than one child and doing bounding box
react_native_assert(getChildren().size() == 1);

if (!this->yogaNode_.getHasNewLayout()) {
return;
}

auto child = std::static_pointer_cast<const YogaLayoutableShadowNode>(
getChildren()[0]);

Expand All @@ -51,6 +47,7 @@ void RNGestureHandlerDetectorShadowNode::layout(LayoutContext layoutContext) {
// TODO: figure out the correct way to setup metrics between detector and
// the child
auto metrics = child->getLayoutMetrics();
metrics.frame = child->getLayoutMetrics().frame;
setLayoutMetrics(metrics);

auto childmetrics = child->getLayoutMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { GestureObjects as Gesture } from '../../handlers/gestures/gestureObject
import { GestureDetector } from '../../handlers/gestures/GestureDetector';
import {
PressableEvent,
PressableProps,
PressableDimensions,
LegacyPressableProps,
} from './PressableProps';
import {
Insets,
Expand Down Expand Up @@ -40,7 +40,7 @@ import { PressableStateMachine } from './StateMachine';
const DEFAULT_LONG_PRESS_DURATION = 500;
const IS_TEST_ENV = isTestEnv();

const Pressable = (props: PressableProps) => {
const Pressable = (props: LegacyPressableProps) => {
const {
testOnly_pressed,
hitSlop,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
View,
} from 'react-native';
import { RelationPropType } from '../utils';
import { AnyGesture } from '../../v3/types';

export type PressableDimensions = { width: number; height: number };

Expand All @@ -30,7 +31,47 @@ export type InnerPressableEvent = {

export type PressableEvent = { nativeEvent: InnerPressableEvent };

export interface PressableProps
export interface LegacyPressableProps extends CommonPressableProps {
/**
* A gesture object or an array of gesture objects containing the configuration and callbacks to be
* used with the Pressable's gesture handlers.
*/
simultaneousWithExternalGesture?: RelationPropType;

/**
* A gesture object or an array of gesture objects containing the configuration and callbacks to be
* used with the Pressable's gesture handlers.
*/
requireExternalGestureToFail?: RelationPropType;

/**
* A gesture object or an array of gesture objects containing the configuration and callbacks to be
* used with the Pressable's gesture handlers.
*/
blocksExternalGesture?: RelationPropType;
}

export interface PressableProps extends CommonPressableProps {
/**
* A gesture object or an array of gesture objects containing the configuration and callbacks to be
* used with the Pressable's gesture handlers.
*/
simultaneousWith?: AnyGesture;

/**
* A gesture object or an array of gesture objects containing the configuration and callbacks to be
* used with the Pressable's gesture handlers.
*/
requireToFail?: AnyGesture;

/**
* A gesture object or an array of gesture objects containing the configuration and callbacks to be
* used with the Pressable's gesture handlers.
*/
block?: AnyGesture;
}

interface CommonPressableProps
extends AccessibilityProps,
Omit<ViewProps, 'children' | 'style' | 'hitSlop'> {
/**
Expand Down Expand Up @@ -149,24 +190,6 @@ export interface PressableProps
*/
unstable_pressDelay?: number;

/**
* A gesture object or an array of gesture objects containing the configuration and callbacks to be
* used with the Pressable's gesture handlers.
*/
simultaneousWithExternalGesture?: RelationPropType;

/**
* A gesture object or an array of gesture objects containing the configuration and callbacks to be
* used with the Pressable's gesture handlers.
*/
requireExternalGestureToFail?: RelationPropType;

/**
* A gesture object or an array of gesture objects containing the configuration and callbacks to be
* used with the Pressable's gesture handlers.
*/
blocksExternalGesture?: RelationPropType;

/**
* @deprecated This property is no longer used, and will be removed in the future.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type {
LegacyPressableProps,
PressableProps,
PressableStateCallbackType,
} from './PressableProps';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
InnerPressableEvent,
PressableEvent,
} from './PressableProps';
import { HoverGestureEvent, LongPressGestureEvent } from '../../v3';

const numberAsInset = (value: number): Insets => ({
left: value,
Expand Down Expand Up @@ -45,9 +46,12 @@ const touchDataToPressEvent = (
});

const gestureToPressEvent = (
event: GestureStateChangeEvent<
HoverGestureHandlerEventPayload | LongPressGestureHandlerEventPayload
>,
event:
| GestureStateChangeEvent<
HoverGestureHandlerEventPayload | LongPressGestureHandlerEventPayload
>
| HoverGestureEvent
| LongPressGestureEvent,
timestamp: number,
targetId: number
): InnerPressableEvent => ({
Expand All @@ -73,9 +77,12 @@ const isTouchWithinInset = (
(touch?.locationY ?? 0) > -(inset.top ?? 0);

const gestureToPressableEvent = (
event: GestureStateChangeEvent<
HoverGestureHandlerEventPayload | LongPressGestureHandlerEventPayload
>
event:
| GestureStateChangeEvent<
HoverGestureHandlerEventPayload | LongPressGestureHandlerEventPayload
>
| HoverGestureEvent
| LongPressGestureEvent
): PressableEvent => {
const timestamp = Date.now();

Expand Down
3 changes: 2 additions & 1 deletion packages/react-native-gesture-handler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ export type {

export type {
PressableProps,
LegacyPressableProps,
PressableStateCallbackType,
} from './components/Pressable';
export { default as Pressable } from './components/Pressable';
export { default as LegacyPressable } from './components/Pressable';

export type { GestureTouchEvent as SingleGestureTouchEvent } from './handlers/gestureHandlerCommon';

Expand Down
Loading
Loading