nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

Zoom was completely disabled, please allow us to control the zoom

Open Swift42 opened this issue 2 years ago • 4 comments

The zoom feature was completely disabled, see here: https://github.com/nwjs/nw.js/issues/7309

It seems there is no way to turn it on optionally. I have an app that is used by normal users, but also by visually impaired users and I want to allow them to zoom (if they want or need to) Please give us a nw.js manifest parameter, so I can decide if I want to allow the zoom feature or not. Doing it programmatically isn't as reliable as doing it directly via nw.js If there would be a parameter, I could provide two app versions: One app with a blocked zoom (=the current default) and one app where zoom is possible. Thank you.

Swift42 avatar Jul 19 '23 11:07 Swift42

Depending on the method of zoom that you want, you can implement your own "zoom" functionality by attaching an event listener to the body and adjusting your initial font size in your body or something.

document.body.addEventListener('keydown', (e) => {
	if(e.ctrlKey && e.key == '+') {
		// do zoom stuffs here using js
	}
});

thisjt avatar Jul 19 '23 18:07 thisjt

I know there are JS solutions, but a better and cleaner way would be a direct zoom support from nw.js And the zoom support is already there, it was just commented out here: https://github.com/nwjs/chromium.src/commit/f6f756d07acac3e146a58dfaf0c0d99d1d43655f So the team would just need to make the zoom support configurable.

Swift42 avatar Jul 19 '23 19:07 Swift42

Seems pretty clean, and uses the browsers full screen zoom capability. No font scale or css needed.

function setZoom(percent) {
    nw.Window.get(window).zoomLevel = Math.log(percent/100.0) / Math.log(1.2);
}

https://docs.nwjs.io/en/latest/References/Window/#winzoomlevel

bluthen avatar Jul 19 '23 21:07 bluthen

although there are many solutions out there, but reimplement a disabled existed function just making people mad, you also need to consider restoring when you restart the app or creating a new window.

liesauer avatar Sep 15 '23 07:09 liesauer