Commit d26e66ca authored by Oleg Korshul's avatar Oleg Korshul

detect browser zoom (chrome)

parent ad739d39
......@@ -116,18 +116,39 @@ AscBrowser.checkZoom = function()
if (AscBrowser.isAndroid)
return;
AscBrowser.zoom = 1.0;
AscBrowser.isRetina = false;
if (AscBrowser.isChrome && !AscBrowser.isOpera && document && document.firstElementChild && document.body)
{
document.firstElementChild.style.zoom = "reset";
AscBrowser.zoom = document.body.clientWidth / window.innerWidth;
if (window.innerWidth > 300)
AscBrowser.zoom = window.outerWidth / window.innerWidth;
if (Math.abs(AscBrowser.zoom - 1) < 0.1)
AscBrowser.zoom = 1;
AscBrowser.zoom = window.outerWidth / window.innerWidth;
var _devicePixelRatio = window.devicePixelRatio / AscBrowser.zoom;
// device pixel ratio: кратно 0.5
_devicePixelRatio = (5 * (((2.5 + 10 * _devicePixelRatio) / 5) >> 0)) / 10;
AscBrowser.zoom = window.devicePixelRatio / _devicePixelRatio;
if (2 == _devicePixelRatio)
AscBrowser.isRetina = true;
// chrome 54.x: zoom = "reset" - clear retina zoom (windows)
//document.firstElementChild.style.zoom = "reset";
document.firstElementChild.style.zoom = 1.0 / AscBrowser.zoom;
}
else
{
AscBrowser.isRetina = (Math.abs(2 - (window.devicePixelRatio / AscBrowser.zoom)) < 0.01);
}
};
AscBrowser.checkZoom();
// detect retina (http://habrahabr.ru/post/159419/)
AscBrowser.isRetina = (Math.abs(2 - (window.devicePixelRatio / AscBrowser.zoom)) < 0.01);
//--------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment