Skip to content
Merged
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
18 changes: 10 additions & 8 deletions src/components/Pressable/Pressable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export default function Pressable(props: PressableProps) {
const pressInHandler = useCallback((event: GestureTouchEvent) => {
props.onPressIn?.(adaptTouchEvent(event));
isPressCallbackEnabled.current = true;
setPressedState(true);
pressDelayTimeoutRef.current = null;
setPressedState(true);
}, []);
const pressOutHandler = useCallback((event: GestureTouchEvent) => {
if (
Expand All @@ -107,7 +107,9 @@ export default function Pressable(props: PressableProps) {
}

if (props.unstable_pressDelay && pressDelayTimeoutRef.current !== null) {
// legacy Pressable behaviour - if pressDelay is set, we want to call onPressIn on touch up
// when delay is preemptively finished by lifting touches,
// we want to immediately activate it's effects - pressInHandler,
// even though we are located at the pressOutHandler
clearTimeout(pressDelayTimeoutRef.current);
pressInHandler(event);
}
Expand Down Expand Up @@ -174,19 +176,19 @@ export default function Pressable(props: PressableProps) {
pressOutHandler(event);
})
.onTouchesCancelled((event) => {
if (handlingOnTouchesDown.current) {
cancelledMidPress.current = true;
onEndHandlingTouchesDown.current = () => pressOutHandler(event);
return;
}

if (
!isPressedDown.current ||
event.allTouches.length > event.changedTouches.length
) {
return;
}

if (handlingOnTouchesDown.current) {
cancelledMidPress.current = true;
onEndHandlingTouchesDown.current = () => pressOutHandler(event);
return;
}

pressOutHandler(event);
}),
[
Expand Down