W3C home > Mailing lists > Public > www-style@w3.org > September 2016

Re: [visualViewport]: Proposal and RFC

From: Marat Tanalin <mtanalin@yandex.ru>
Date: Wed, 07 Sep 2016 18:05:55 +0300
To: Yash Malik <ymalik@google.com>, David Bokan <bokan@google.com>, "www-style@w3.org" <www-style@w3.org>
Message-Id: <440721473260755@web28j.yandex.ru>
07.09.2016, 17:27, "Yash Malik" <ymalik@google.com>:
>> 2. contains zoom relative to that already reflected in `window.devicePixelRatio`, so the total physical-pixels-per-logical-pixel ratio can be calculated as the _product_ of `window.visualViewport.scale` times `window.devicePixelRatio`?
> By physical-pixels-per-logical-pixel, do you mean physical-pixels-per-css-pixels? If so, then almost*. `window.visualViewport.scale` times  `window.devicePixelRatio` doesn't take the browser zoom into account.

Physical-pixels-per-css-pixel ratio is exactly what `window.devicePixelRatio` is about, and it _does_ account for browser-level zoom at least in Firefox.

What I'm interested in is determining _total_ zoom that includes _both_ `window.devicePixelRatio` and pinch zoom, so that it's possible to determine exact image (<img>) size in _physical_ pixels. Currently, I'm using the following formula for this purpose in Firefox for Android:

    (image.width / image.naturalWidth) * window.devicePixelRatio * (window.outerWidth / window.innerWidth)

where `window.outerWidth / window.innerWidth` is pinch zoom that, as I suspect, `window.visualViewport.scale` is supposed to be a legit reliable equivalent of. So, if I understand correctly, the new reliable formula would be:

    (image.width / image.naturalWidth) * window.devicePixelRatio * `window.visualViewport.scale`

Do I understand `window.visualViewport.scale` purpose correctly?
Received on Wednesday, 7 September 2016 15:06:31 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:04 UTC