MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Feature]: Add WillZoomFactorChange event
@Lakshmisha-KS is already working on this.
Since Feb 12, 2025.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
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 had zoom-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 to false and tried listening for the WebView control's MouseWheel event, but that doesn't fire due to https://github.com/MicrosoftEdge/WebView2Feedback/issues/1040
So 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 happens
What does your app do? Is there a pending deadline for this request?
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.