Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix LongPressGestureHandler web discrepancy on move events #1098

Merged
merged 1 commit into from
Sep 22, 2020
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
9 changes: 6 additions & 3 deletions createHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ export default function createHandler(
this._createGestureHandler(
filterConfig(
transformProps ? transformProps(this.props) : this.props,
{ ...this.constructor.propTypes, ...customNativeProps },
{
...(this.constructor.propTypes || propTypes),
...customNativeProps,
},
config
)
);
Expand All @@ -254,7 +257,7 @@ export default function createHandler(
_update() {
const newConfig = filterConfig(
transformProps ? transformProps(this.props) : this.props,
{ ...this.constructor.propTypes, ...customNativeProps },
{ ...(this.constructor.propTypes || propTypes), ...customNativeProps },
config
);
if (!deepEqual(this._config, newConfig)) {
Expand All @@ -266,7 +269,7 @@ export default function createHandler(
const mergedProps = { ...this.props, ...updates };
const newConfig = filterConfig(
transformProps ? transformProps(mergedProps) : mergedProps,
{ ...this.constructor.propTypes, ...customNativeProps },
{ ...(this.constructor.propTypes || propTypes), ...customNativeProps },
config
);
this._updateGestureHandler(newConfig);
Expand Down
38 changes: 23 additions & 15 deletions web/PressGestureHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,32 @@ class PressGestureHandler extends DiscreteGestureHandler {

onRawEvent(ev) {
super.onRawEvent(ev);
if (ev.isFinal && this.isGestureRunning) {
let timeout;
if (this.visualFeedbackTimer) {
// Aesthetic timing for a quick tap.
// We haven't activated the tap right away to emulate iOS `delaysContentTouches`
// Now we must send the initial activation event and wait a set amount of time before firing the end event.
timeout = CONTENT_TOUCHES_QUICK_TAP_END_DELAY;
this.sendGestureStartedEvent(this.initialEvent);
this.initialEvent = null;
}
fireAfterInterval(() => {
if (this.isGestureRunning) {
if (ev.isFinal) {
let timeout;
if (this.visualFeedbackTimer) {
// Aesthetic timing for a quick tap.
// We haven't activated the tap right away to emulate iOS `delaysContentTouches`
// Now we must send the initial activation event and wait a set amount of time before firing the end event.
timeout = CONTENT_TOUCHES_QUICK_TAP_END_DELAY;
this.sendGestureStartedEvent(this.initialEvent);
this.initialEvent = null;
}
fireAfterInterval(() => {
this.sendEvent({
...ev,
eventType: Hammer.INPUT_END,
isFinal: true,
});
this.onGestureEnded();
}, timeout);
} else {
this.sendEvent({
...ev,
eventType: Hammer.INPUT_END,
isFinal: true,
eventType: Hammer.INPUT_MOVE,
isFinal: false,
});
this.onGestureEnded();
}, timeout);
}
}
}

Expand Down