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

WebView2 in ScrollViewer #7902

Open
andrewdewaal opened this issue Nov 9, 2022 · 5 comments
Open

WebView2 in ScrollViewer #7902

andrewdewaal opened this issue Nov 9, 2022 · 5 comments
Labels
area-WebView feature proposal New feature proposal product-winui3 WinUI 3 issues team-Rendering Issue for the Rendering team

Comments

@andrewdewaal
Copy link

   The approach proposed here is probably not going to happen. If WebView2 drew into an enormous surface the width/height of the entire page, that would provide the desired smooth scrolling experience but would have a huge performance cost for that surface. That surface cost could be mitigated if WebView2 drew into a XAML VirtualSurfaceImageSource, which would require significant design changes and other complexities due to the WebView2 Runtime rendering outside of the app process.

Originally posted by @codendone in #5654 (comment)

We are in the process of migrating from WebView to WebView2. Our application allows a user to interact with HTML content (such as highlighting), and allows swiping to the previous or next content. Our implementation for this was, from a high level, a FlipView wherein each FlipViewItem contained a WebView.
Since WebView2 consumes all scroll and pan actions, we have lost our ability to swipe to content unless we disable the webview, in which case the user can't interact with the content.
To confirm your previous statement, there isn't a way presently to use a WebView2 (allowing user interaction) within a ScrollViewer? If that is the case, is there a possibility of adding this functionality?
Thanks very much!

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Nov 9, 2022
@codendone
Copy link
Contributor

From an underlying implementation perspective, the FlipView scenario is the same as #4596. My comment from that issue applies here as well:

We call this "scroll chaining", where any unusable amount of scrolling will chain up to parent containers. This is something we plan to support, but we don't currently have an ETA for this.

It is still the case that we want to support this eventually and don't currently have an ETA.

@codendone codendone added area-WebView team-Rendering Issue for the Rendering team product-winui3 WinUI 3 issues and removed needs-triage Issue needs to be triaged by the area owners labels Nov 10, 2022
@nbevans
Copy link

nbevans commented Jan 26, 2023

This is quite frustrating that scroll chaining is not supported and neither is any way to disable the capture of the PointerWheelChanged events. Due to the lower level way that WebView2 sets up its event hooks for pointer events, it seems to bypass all the conventional means available to control event routing in UWP apps.

@nbevans
Copy link

nbevans commented Jan 26, 2023

It seems to be possible to hackily get an acceptable workaround by using a pattern like this:

Essentially it hooks the pointer wheel event, and disables hit testing entirely, then uses a debouncer to re-enable hit testing after 500ms of no further pointer wheel events. This gives the effect that when scrolling your ScrollView, the WebView2 doesn't stop the scrolling. But it still allows for interactivity with the WebView2 e.g. mouse hover/clicks events still work.


        public class SingaporeWebView2Wrapper : X.Controls.UserControl {
            public WebView2 WebView2 { get; }
            public SingaporeWebView2Wrapper(WebView2 webView2) {
                WebView2 = webView2;
                Content = webView2;

                timer = DispatcherQueue.GetForCurrentThread().CreateTimer();
                webView2.PointerWheelChanged += WebView2_PointerWheelChanged;
            }

            private DispatcherQueueTimer timer;

            private void WebView2_PointerWheelChanged(object sender, PointerRoutedEventArgs e) {
                System.Diagnostics.Trace.WriteLine("IsHitTestVisible = " + WebView2.IsHitTestVisible);
                WebView2.IsHitTestVisible = false;
                timer.Debounce(() => {
                    WebView2.IsHitTestVisible = true;
                    System.Diagnostics.Trace.WriteLine("IsHitTestVisible = " + WebView2.IsHitTestVisible);
                }, TimeSpan.FromMilliseconds(500));
            }
        }

@michael-hawker
Copy link
Collaborator

Related to #108 I suppose too?

@andrewdewaal
Copy link
Author

andrewdewaal commented Jul 13, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-WebView feature proposal New feature proposal product-winui3 WinUI 3 issues team-Rendering Issue for the Rendering team
Projects
None yet
Development

No branches or pull requests

5 participants