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

Cancel handlers by NativeViewGestureHandler #2788

Merged
merged 9 commits into from
Mar 7, 2024
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
11 changes: 5 additions & 6 deletions src/web/handlers/NativeViewGestureHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,10 @@ export default class NativeViewGestureHandler extends GestureHandler {
const view = this.delegate.getView() as HTMLElement;

view.style['touchAction'] = 'auto';

//@ts-ignore Turns on defualt touch behavior on Safari
view.style['WebkitTouchCallout'] = 'auto';

if (view.hasAttribute('role')) {
this.buttonRole = true;
} else {
this.buttonRole = false;
}
this.buttonRole = view.getAttribute('role') === 'button';
}

public updateGestureConfig({ enabled = true, ...props }: Config): void {
Expand Down Expand Up @@ -164,4 +159,8 @@ export default class NativeViewGestureHandler extends GestureHandler {
public disallowsInterruption(): boolean {
return this.disallowInterruption;
}

public isButton(): boolean {
return this.buttonRole;
}
}
11 changes: 8 additions & 3 deletions src/web/tools/InteractionManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { State } from '../../State';
import GestureHandler from '../handlers/GestureHandler';
import NativeViewGestureHandler from '../handlers/NativeViewGestureHandler';
import { Config, Handler } from '../interfaces';

export default class InteractionManager {
Expand Down Expand Up @@ -102,10 +104,13 @@ export default class InteractionManager {

public shouldHandlerBeCancelledBy(
_handler: GestureHandler,
_otherHandler: GestureHandler
otherHandler: GestureHandler
): boolean {
//TODO: Implement logic
return false;
return (
otherHandler instanceof NativeViewGestureHandler &&
otherHandler.getState() === State.ACTIVE &&
!otherHandler.isButton()
);
}

public dropRelationsForHandlerWithTag(handlerTag: number): void {
Expand Down
Loading