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

[InAppWebView] double click but touchstart event only trigger once #216

Closed
OPY-bbt opened this issue Dec 11, 2019 · 10 comments
Closed

[InAppWebView] double click but touchstart event only trigger once #216

OPY-bbt opened this issue Dec 11, 2019 · 10 comments

Comments

@OPY-bbt
Copy link

OPY-bbt commented Dec 11, 2019

Environment

Flutter version: 1.10.15
Plugin version: 2.1.0+1
Android version:
iOS version: 13.1.3
Xcode version: xcode 11.1
Device information: iOS

Description

I use InAppWebView load html, then double click div tag, but only trigger once event;

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            font-size: 30px;
        }
    </style>
</head>
<body>
    <div>click</div>
    <script>
        document.querySelector('div').addEventListener('touchstart', function() {
            console.log('click');
        });
    </script>
</body>
</html>

Expected behavior:
two click log
Current behavior:
one click log

This was referenced Jul 6, 2020
@swordyy7
Copy link

I have the same issue, did you solve it?

@OPY-bbt
Copy link
Author

OPY-bbt commented Oct 27, 2021

I have the same issue, did you solve it?

The problem was not solved.

@swordyy7
Copy link

I debugged my demo
, It is found that the FlutterTouchInterceptingView DelayingGestureRecognizer interception is an event

@swordyy7
Copy link

swordyy7 commented Nov 27, 2021

I added the following code and it works as expected:

override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        
        let view = super.hitTest(point, with: event);
        
        let gestureRecognizers = self.superview?.superview?.gestureRecognizers ?? []
        for gesture in gestureRecognizers{
        
            gesture.isEnabled = false
        }
        return view
    }```

@lucashsilva
Copy link

I have the same issue and that code snippet solved it. However, I'm not sure if it impacts something else.

@matovnikov
Copy link

Hi! Tell me, where do I need to add this code?

@swordyy7
Copy link

Hi! Tell me, where do I need to add this code?

flutter/flutter#94325 (comment)

@JoaaoVerona
Copy link

Thanks @swordyy7 for the fix!

To anyone else who wants to try this fix, I just published a fork of flutter_inappwebview with the touch delay fix provided by @swordyy7.

  • flutter pub remove flutter_inappwebview
  • flutter pub add flutter_inappwebview_fix_iostouchdelay
  • Update your imports from flutter_inappwebview to flutter_inappwebview_fix_iostouchdelay, example:
    • From: import "package:flutter_inappwebview/flutter_inappwebview.dart";
    • To: import "package:flutter_inappwebview_fix_iostouchdelay/flutter_inappwebview_fix_iostouchdelay.dart";

The forked library is listed on pub.dev here, and the source code is here.

Hope this helps someone. :)

@deekshithdv
Copy link

@swordyy7
The code snippet resolve the touch issue but it disables the interaction with any flutter native components displayed on top of the WebView! :(

Copy link

github-actions bot commented Oct 6, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants