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 @@ -537,7 +537,7 @@ open class GestureHandler {
}

private fun cancelPointers() {
touchEventType = RNGestureHandlerTouchEvent.EVENT_TOUCH_CANCELLED
touchEventType = RNGestureHandlerTouchEvent.EVENT_TOUCH_CANCEL
changedTouchesPayload = null
extractAllPointersData()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RNGestureHandlerTouchEvent private constructor() : Event<RNGestureHandlerT
const val EVENT_TOUCH_DOWN = 1
const val EVENT_TOUCH_MOVE = 2
const val EVENT_TOUCH_UP = 3
const val EVENT_TOUCH_CANCELLED = 4
const val EVENT_TOUCH_CANCEL = 4

const val EVENT_NAME = "onGestureHandlerEvent"
const val REANIMATED_EVENT_NAME = "onGestureHandlerReanimatedTouchEvent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ typedef NS_ENUM(NSInteger, RNGHTouchEventType) {
RNGHTouchEventTypePointerDown,
RNGHTouchEventTypePointerMove,
RNGHTouchEventTypePointerUp,
RNGHTouchEventTypeCancelled,
RNGHTouchEventTypePointerCancel,
};
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ - (void)cancelPointers
}
}

_eventType = RNGHTouchEventTypeCancelled;
_eventType = RNGHTouchEventTypePointerCancel;
_changedPointersData = [[NSArray alloc] initWithObjects:data count:registeredTouches];
[self sendEvent];
_trackedPointersCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const TouchEventType = {
TOUCHES_DOWN: 1,
TOUCHES_MOVE: 2,
TOUCHES_UP: 3,
TOUCHES_CANCELLED: 4,
TOUCHES_CANCEL: 4,
} as const;

// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function getHandler(
return gesture.onTouchesMove;
case CALLBACK_TYPE.TOUCHES_UP:
return gesture.onTouchesUp;
case CALLBACK_TYPE.TOUCHES_CANCELLED:
case CALLBACK_TYPE.TOUCHES_CANCEL:
return gesture.onTouchesCancelled;
}
}
Expand All @@ -54,8 +54,8 @@ function touchEventTypeToCallbackType(
return CALLBACK_TYPE.TOUCHES_MOVE;
case TouchEventType.TOUCHES_UP:
return CALLBACK_TYPE.TOUCHES_UP;
case TouchEventType.TOUCHES_CANCELLED:
return CALLBACK_TYPE.TOUCHES_CANCELLED;
case TouchEventType.TOUCHES_CANCEL:
return CALLBACK_TYPE.TOUCHES_CANCEL;
}
return CALLBACK_TYPE.UNDEFINED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function onGestureHandlerEvent(
case TouchEventType.TOUCHES_UP:
handler.handlers?.onTouchesUp?.(event, manager);
break;
case TouchEventType.TOUCHES_CANCELLED:
case TouchEventType.TOUCHES_CANCEL:
handler.handlers?.onTouchesCancelled?.(event, manager);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const CALLBACK_TYPE = {
TOUCHES_DOWN: 7,
TOUCHES_MOVE: 8,
TOUCHES_UP: 9,
TOUCHES_CANCELLED: 10,
TOUCHES_CANCEL: 10,
} as const;

// Allow using CALLBACK_TYPE as object and type
Expand Down Expand Up @@ -274,7 +274,7 @@ export abstract class BaseGesture<
onTouchesCancelled(callback: TouchEventHandlerType) {
this.config.needsPointerData = true;
this.handlers.onTouchesCancelled = callback;
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCELLED] =
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCEL] =
this.isWorklet(callback);

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ export function extractUpdateHandlers<THandlerData, TConfig>(
export function extractTouchHandlers<THandlerData, TConfig>(
config: BaseGestureConfig<THandlerData, TConfig>
): GestureCallbacks<THandlerData> {
const { onTouchesDown, onTouchesMove, onTouchesUp, onTouchesCancelled } =
config;
const { onTouchesDown, onTouchesMove, onTouchesUp, onTouchesCancel } = config;

const handlers: GestureCallbacks<THandlerData> = {
...(onTouchesDown ? { onTouchesDown } : {}),
...(onTouchesMove ? { onTouchesMove } : {}),
...(onTouchesUp ? { onTouchesUp } : {}),
...(onTouchesCancelled ? { onTouchesCancelled } : {}),
...(onTouchesCancel ? { onTouchesCancel } : {}),
};

return handlers;
Expand Down Expand Up @@ -79,8 +78,8 @@ export function getHandler<THandlerData>(
return callbacks.onTouchesMove;
case CALLBACK_TYPE.TOUCHES_UP:
return callbacks.onTouchesUp;
case CALLBACK_TYPE.TOUCHES_CANCELLED:
return callbacks.onTouchesCancelled;
case CALLBACK_TYPE.TOUCHES_CANCEL:
return callbacks.onTouchesCancel;
}
}

Expand All @@ -95,8 +94,8 @@ export function touchEventTypeToCallbackType(
return CALLBACK_TYPE.TOUCHES_MOVE;
case TouchEventType.TOUCHES_UP:
return CALLBACK_TYPE.TOUCHES_UP;
case TouchEventType.TOUCHES_CANCELLED:
return CALLBACK_TYPE.TOUCHES_CANCELLED;
case TouchEventType.TOUCHES_CANCEL:
return CALLBACK_TYPE.TOUCHES_CANCEL;
}
return CALLBACK_TYPE.UNDEFINED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function shouldHandleTouchEvents<THandlerData, TConfig>(
!!config.onTouchesDown ||
!!config.onTouchesMove ||
!!config.onTouchesUp ||
!!config.onTouchesCancelled
!!config.onTouchesCancel
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const HandlerCallbacks = new Set<
'onTouchesDown',
'onTouchesMove',
'onTouchesUp',
'onTouchesCancelled',
'onTouchesCancel',
]);

export const PropsToFilter = new Set<BaseGestureConfig<unknown, unknown>>([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ export type GestureCallbacks<THandlerData> = {
onStart?: (event: GestureStateChangeEvent<THandlerData>) => void;
onEnd?: (
event: GestureStateChangeEvent<THandlerData>,
success: boolean
didSucceed: boolean

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll bring this topic once again, what about moving didSucceed into event? This can be both good and bad idea at the same time, so let me know what you think 😅

@j-piasecki j-piasecki Nov 14, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It already is inside the event, kind of. didSucceed is true when the new state is END, and false when the new state is CANCELLED or FAILED.

We can come back to the idea together with changing the state info. Do we want to hide the state info from the public API entirely?

I'll go with merging this for now, since this rename doesn't change the discussion in any way 😅.

) => void;
onFinalize?: (
event: GestureStateChangeEvent<THandlerData>,
success: boolean
didSucceed: boolean
) => void;
onUpdate?: (event: GestureUpdateEvent<THandlerData>) => void | AnimatedEvent;
onTouchesDown?: (event: GestureTouchEvent) => void;
onTouchesMove?: (event: GestureTouchEvent) => void;
onTouchesUp?: (event: GestureTouchEvent) => void;
onTouchesCancelled?: (event: GestureTouchEvent) => void;
onTouchesCancel?: (event: GestureTouchEvent) => void;
};

export type GestureRelations = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ export default abstract class GestureHandler implements IGestureHandler {
eventType = TouchEventType.TOUCHES_MOVE;
break;
case EventTypes.CANCEL:
eventType = TouchEventType.TOUCHES_CANCELLED;
eventType = TouchEventType.TOUCHES_CANCEL;
break;
}

Expand Down Expand Up @@ -655,7 +655,7 @@ export default abstract class GestureHandler implements IGestureHandler {
nativeEvent: {
handlerTag: this.handlerTag,
state: this.state,
eventType: TouchEventType.TOUCHES_CANCELLED,
eventType: TouchEventType.TOUCHES_CANCEL,
changedTouches: changed,
allTouches: all,
numberOfTouches: all.length,
Expand Down
Loading