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

Scroll Problem on a Scrollable Screen #101

Open
bahricanyesil opened this issue Jan 16, 2024 · 3 comments
Open

Scroll Problem on a Scrollable Screen #101

bahricanyesil opened this issue Jan 16, 2024 · 3 comments

Comments

@bahricanyesil
Copy link

When I add a web view inside a screen that is scrollable, the mouse wheel actions are recognized by both the web view and the screen. Take the following case as an example:
I have a chart on a scrollable screen. Normally, the chart should zoom in/out when the mouse wheel is scrolled and the screen should NOT scroll. However, the screen is also scrolling while using this package. I am also using flutter_inappwebview package for the web platform. When I run the app on a desktop web, it does not have this issue. What can be the reason and how to fix it? @SinyimZhi Thanks from now on.

@SinyimZhi
Copy link
Collaborator

@bahricanyesil I think it is caused we didn't prevent the onPointerSignal event passed to the parent widget. Can you try to find webview.dart line 460 and change the code like this
image
the code is here if (p is PointerScrollEvent) { _controller._setScrollDelta(p.localPosition, p.scrollDelta.dx.round(), p.scrollDelta.dy.round()); }

@bahricanyesil
Copy link
Author

bahricanyesil commented Jan 17, 2024

Thanks for your quick response @SinyimZhi. I found and updated the related section in the webview.dart file as follows:

 onPointerSignal: (signal) {
            GestureBinding.instance.pointerSignalResolver.register(signal, (p) {
              if (p is PointerScrollEvent) {
                _controller._setScrollDelta(p.localPosition,
                    p.scrollDelta.dx.round(), p.scrollDelta.dy.round());
              }
            });
          },

The issue has gone and now we can scroll inside webview by preventing passing the scroll event to the parent.

Thank you so much @SinyimZhi 🙏 🥳

@bahricanyesil
Copy link
Author

@SinyimZhi How to achieve the same thing for the hold and move action with the left click? I also want to disable parent actions for that type of event and only handle them inside the webview. Those events are types of onPointerMove/onPointerUp/onPointerDown instead of onPointerSignal. How to determine which widget handles those events, can you help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants