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

Window.zoomLevel is arbitrary #2023

Open
M-Pixel opened this issue Jun 29, 2014 · 8 comments
Open

Window.zoomLevel is arbitrary #2023

M-Pixel opened this issue Jun 29, 2014 · 8 comments

Comments

@M-Pixel
Copy link

M-Pixel commented Jun 29, 2014

The wiki currently states

Window.zoomLevel
since v0.4.1

Get or Set the page zoom. 0 for normal size; positive value for zooming in; negative value for zooming out.

It seems to me that "default" should be 1, for 100%. How do I zoom to 150%? Is it 0.5? How do I zoom to 50%, -0.5? Neither would make sense.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@JovankaB
Copy link

I agree, it would be more intuitive. Also you would be able to do something like win.zoomLevel *= 2; to double the zoom level regardless of the current zoom. Right now it seems to be impossible. You can set some number, but it's not clear what is the current zoom level in percentage.

@kitingChris
Copy link

Well very sad this is not clarified...
I want to work as well with the zoomLevel but there is a quite lack of information about it :(

@kingslou
Copy link

为什么总是自动发邮箱邮件啊 好烦人啊

@rogerwang
Copy link
Member

The actual zoom factor = pow(1.2, L) or 1.2^L where L is the zoom level.

See https://github.com/nwjs/blink/blob/2664bfe8de3a82d3d808cd13e8bcb209a01c8232/Source/web/WebViewImpl.cpp#L2827

@kitingChris
Copy link

Great thanks. But might it be possible to use a more familiar percentage zoom solution? In my opinion that might be a better option cause css standard also uses percentage.

@loveencounterflow
Copy link

in my app i stopped using the application zoom level and replaced it by CSS transitions; this has several advantages:

  • you can control what you want to zoom, so that e.g. interface tools remain unzoomed;
  • you get smooth transitions for free which look so much better than a jumping zoom;
  • plus in CSS zooming is tantamount to scaling, and 'scale' is just an intuitive factor—1 means original size, 2 means twice as big, and 0.5 is half as big.

Since i've implemented this i only use the application zoom to select an initial app zoom state so that a scale of 1 means that 1mm in the CSS approximately matches 1mm on the screen, but even for that an additional factor in the CSS might be used.

The only case where application still matters to me is the fact that font and box metrics seem to be more fractional / numerically unstable (?) at small app zoom levels (i have an open question on this problem on http://stackoverflow.com/questions/29035656/why-do-rendered-pixels-differ-from-real-pixels; maybe you people have an idea what's going on?).

+1 for app zoom support that uses a scaling factor and supports smooth zooming. Then again, you can easily implement it yourself.

@felicienfrancois
Copy link

var zoomPercent = 150;
var win = require("nw.gui").Window.get();
win.zoomLevel = Math.log(zoomPercent/100) / Math.log(1.2);

@loveencounterflow
Copy link

Does that mean that the zoom level is the logarithm to base 1.2 of the scaling factor?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants