-
Notifications
You must be signed in to change notification settings - Fork 54
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
[Feature]: Add WillZoomFactorChange event #4522
Comments
Actually, this is more important to have than I initially thought. In Electron, I would intercept the zoom-changed event and handle the zoom manually. Here, if zoom is enabled for the control, the zoom happens automatically and I can't cancel it. My app puts a limit on how far you can zoom in. So if zoom happens automatically, I can't enforce the limit (or I can zoom you out after, but that looks very choppy) So I tried intercepting the WebView2's WheelDown event but that's apparently not supported according to another issue (and I verified that the handler never fires) So I tried injecting JS into every frame on navigationcompleted to listen JS's This sometimes works, but not for all iframes (all same origin). No idea why. I can see that the postmessage function is defined, but after it gets called, my handler (webMessageReceived) never gets hit. No errors. No exceptions in devtools. Same issue when using host objects via AddHostObject APIs. Sometimes it works, sometimes it doesn't. haven't been able to repro in a minimal example though. |
@victorhuangwq they're separate issues. That one is about the existing ZoomFactorChanged event. Though I really would like zoom direction exposed in this new event as well. |
@victorhuangwq And one nuance in Electron is that if a page intercepts the |
Describe the feature/enhancement you need
Currently, there's an ZoomFactorChanged event that fires after the zoom factor has changed.
My app wants to prevent zooming all the way in. If the window is small, we might want to stop you half way, say.
To achieve this, I was playing around with hooking into the
ZoomFactorChanged
event and detecting if we zoomed to far, but the problem is at that point we already finished zooming, so I need to undo the zoom which looks choppy. (in Electron, they hadzoom-changed
event which fires without any actual zooming happening since Electron disables zoom by default and we have to intercept and handle it programmatically)So instead I set
IsZoomControlEnabled
tofalse
and tried listening for the WebView control'sMouseWheel
event, but that doesn't fire due to #1040So I'm having to use the workaround mentioned and execute JS on every navigation to intercept the
wheel
event and post back the response.It would be nicer if there were an event I could hook into before the zoom actually happened where I could also cancel the zoom.
The scenario/use case where you would use this feature
see above (detect zoom but cancel it and do custom handling)
How important is this request to you?
Nice to have. There are other ways to tackle this, but having official API support would be beneficial.Actually, very important now.
Suggested implementation
a
WillZoomFactorChange
type of event where I can cancel the zoom before it happensWhat does your app do? Is there a pending deadline for this request?
No response
AB#54703408
The text was updated successfully, but these errors were encountered: