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

[feat] zoom in and out functionality (ctrl/ctrl+shift + "=" and ctrl/ctrl+shift+ "-") #3310

Closed
pinnick opened this issue Jan 30, 2022 · 23 comments · Fixed by #9378
Closed

[feat] zoom in and out functionality (ctrl/ctrl+shift + "=" and ctrl/ctrl+shift+ "-") #3310

pinnick opened this issue Jan 30, 2022 · 23 comments · Fixed by #9378
Labels
status: backlog Issue is ready and we can work on it type: feature request

Comments

@pinnick
Copy link

pinnick commented Jan 30, 2022

Describe the problem

Browsers such as edge and chrome have a zoom in and out functionality with hotkeys mentioned in the title, and I would like to include that in my application with tauri, but the hotkeys aren't working for me.

Describe the solution you'd like

add the hotkey support

Alternatives considered

No response

Additional context

No response

@FabianLars
Copy link
Member

tracking issue at tauri-apps/wry#388

@martpie
Copy link

martpie commented May 10, 2022

It would seem the upstream has been fixed, I guess now it's just about extending the MenuItem enum and implementing what has been done on wry right?

I may help with that if this is begginer-friendly enough

@keiya01
Copy link
Member

keiya01 commented May 10, 2022

I think this issue is related to tauri-apps/wry#569 .
And it is work in progress in tauri-apps/wry#574 .

@candrewlee14
Copy link

Looks like the upstream issues this depends on have been resolved. What can I do to enable this?

@amrbashir amrbashir added the status: backlog Issue is ready and we can work on it label Sep 19, 2022
@amrbashir
Copy link
Member

even though it landed in upstream, tauri still needs to expose it.

@rajatkulkarni95
Copy link

Bumping this up. Any idea when we'd get this into the framework?

@Looky1173
Copy link

Bumping this up again! This would be a welcome addition to Tauri, mainly for accessibility concerns.

@salmenf
Copy link

salmenf commented Jan 9, 2023

Is there any workaround? I hope this gets added soon, would be great to have for accessibility.

@mxismean
Copy link

mxismean commented Feb 10, 2023

image

Can tauri add a new `zoom` configuration item in the tauri.conf.json configuration file. @FabianLars

This allows users to set the default zoom of the window

@mxismean
Copy link

A year has passed. I want to know how the progress of this bug is?
When can TAURI support Zoom?
@FabianLars

@abose
Copy link

abose commented Nov 1, 2023

In the meantime, there is a pure js based way to get Zoom working in Tauri.
using document.body.style.zoom = 1.5 from JS worked flawlessly in Windows, mac, and Linux Taui 1.5 builds. So there is a pure browser-based way to do this for now as its support in both Chromium (Tauri windows) and web-kit(Tauri mac/linux) (But not Firefox.)

So one could listen to the shortcut and do this Zoom JS thingy to make Zoom work in most cases. There are some caveats to this approach as iframes are not affected by Zoom and other things some edge cases wont work as expeced in some cases.

@phudtran
Copy link

phudtran commented Nov 4, 2023

Also looking forward to this for accessibility.

@zeenix
Copy link
Contributor

zeenix commented Dec 4, 2023

In the meantime, there is a pure js based way to get Zoom working in Tauri.
using document.body.style.zoom = 1.5 from JS worked flawlessly in Windows, mac, and Linux Taui 1.5 builds.

But how can a user of an app do that?

@StenniHub
Copy link

In the meantime, there is a pure js based way to get Zoom working in Tauri. using document.body.style.zoom = 1.5 from JS worked flawlessly in Windows, mac, and Linux Taui 1.5 builds. So there is a pure browser-based way to do this for now as its support in both Chromium (Tauri windows) and web-kit(Tauri mac/linux) (But not Firefox.)

So one could listen to the shortcut and do this Zoom JS thingy to make Zoom work in most cases. There are some caveats to this approach as iframes are not affected by Zoom and other things some edge cases wont work as expeced in some cases.

This is not equivalent to zoom in browsers or in electron. For example some elements that would extend to window borders at 1.0 zoom level will cut off early if you reduce it through document.body.style.zoom.

@abose
Copy link

abose commented Dec 27, 2023

Hi all, managed to fix this by calling the webviews scale API from rust. See This pull request for the code changes needed(it's not much) phcode-dev/phoenix-desktop#162 .

After this , call the js zoom_window API.

     await __TAURI__.tauri.invoke("zoom_window", {scaleFactor:1.2});

Tested working in Windows, Linux, and mac.

@KaKi87
Copy link

KaKi87 commented Dec 27, 2023

How about reading the value, though ?
Because when the user presses Ctrl++/-, we need to increment/decrement the value, requiring knowing it beforehand.
Thanks

@abose
Copy link

abose commented Dec 27, 2023

How about reading the value, though ?
Because when the user presses Ctrl++/-, we need to increment/decrement the value, requiring knowing it beforehand.
Thanks

We use our own storage layer for persisting preferences as browser local storage is not reliable in tauri. You can test with local storage though where you start with 1 in a zoom jey stored in storage and increment zoom by .1 on ctrl+ keyboard shortcut and decrement on.keyboard minus. So we don't really have to read back the scaling factor back from rust layer, instead use localstorage at browser side.

@KaKi87
Copy link

KaKi87 commented Dec 27, 2023

That's unreliable as well, because there's no way to ensure that zoom isn't changeable by any other means.

@abose
Copy link

abose commented Dec 28, 2023

That is probably how chrome/browser internally handles the zoom scale storage too, someone has to store the zoom scale factor to restore it later. If not the webkit layer, then we do it at the application side. It is pretty reliable as long as your storage layer is reliable.

@KaKi87
Copy link

KaKi87 commented Dec 28, 2023

In Chrome, zoom can be changed in many ways : command line arguments, hamburger menu, Ctrl+wheel, Ctrl+keyboard...
So, it's stored somewhere all these inputs can be tracked.
So, in Tauri, storing this in the app would be unreliable as zoom will eventually be changeable from all these places as well.

@namduong-arbin
Copy link

namduong-arbin commented Mar 13, 2024

Hi all, managed to fix this by calling the webviews scale API from rust. See This pull request for the code changes needed(it's not much) phcode-dev/phoenix-desktop#162 .

After this , call the js zoom_window API.

     await __TAURI__.tauri.invoke("zoom_window", {scaleFactor:1.2});

Tested working in Windows, Linux, and mac.

it worked for me. Thank a lot

@KaKi87
Copy link

KaKi87 commented Apr 5, 2024

Windows Only

Uh, why ?

@Legend-Master
Copy link
Contributor

This API is only available in Windows webview2, but we can provide a polyfill as mentioned here #9352 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backlog Issue is ready and we can work on it type: feature request
Projects
Status: 📬Proposal
Development

Successfully merging a pull request may close this issue.