Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -275,11 +275,12 @@ - (void)handleTouchUpOutside:(UIView *)sender forEvent:(UIEvent *)event

- (void)handleTouchUpInside:(UIView *)sender forEvent:(UIEvent *)event
{
[self sendEventsInState:RNGestureHandlerStateEnd
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES
withNumberOfTouches:event.allTouches.count
withPointerType:_pointerType]];
RNGestureHandlerEventExtraData *extraData = [RNGestureHandlerEventExtraData forPointerInside:YES
withNumberOfTouches:event.allTouches.count
withPointerType:_pointerType];

[self sendActiveStateEventIfChangedForView:sender extraData:extraData];
[self sendEventsInState:RNGestureHandlerStateEnd forViewWithTag:sender.reactTag withExtraData:extraData];
Comment thread
j-piasecki marked this conversation as resolved.
}

- (void)handleDragExit:(UIView *)sender forEvent:(UIEvent *)event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class InnerBaseButton extends React.Component<BaseButtonWithRefProps> {
nativeEvent,
}: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>) => {
const { state, oldState, pointerInside } = nativeEvent;
const active = pointerInside && state === State.ACTIVE;
const active =
pointerInside && (state === State.BEGAN || state === State.ACTIVE);
Comment thread
m-bert marked this conversation as resolved.
Outdated

if (active !== this.lastActive && this.props.onActiveStateChange) {
this.props.onActiveStateChange(active);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { Component } from 'react';
import { Animated, Platform } from 'react-native';
import { Animated } from 'react-native';

import type {
GestureEvent,
Expand Down Expand Up @@ -174,10 +174,7 @@ export default class GenericTouchable extends Component<
// Need to handle case with external cancellation (e.g. by ScrollView)
this.moveToState(TOUCHABLE_STATE.UNDETERMINED);
} else if (
// This platform check is an implication of slightly different behavior of handlers on different platform.
// And Android "Active" state is achieving on first move of a finger, not on press in.
// On iOS event on "Began" is not delivered.
state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&
state === State.BEGAN &&
this.STATE === TOUCHABLE_STATE.UNDETERMINED
) {
// Moving inside requires
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ export const BaseButton = (props: BaseButtonProps) => {
};

const onDeactivate = (e: EndCallbackEventType) => {
props.onDeactivate?.(e);
};

const onFinalize = (e: EndCallbackEventType) => {
onActiveStateChange?.(false);

if (!e.canceled && !longPressDetected.current) {
onPress?.(e.pointerInside);
}

props.onDeactivate?.(e);
};

const onFinalize = (e: EndCallbackEventType) => {
if (longPressTimeout.current !== undefined) {
clearTimeout(longPressTimeout.current);
longPressTimeout.current = undefined;
Expand Down
Loading