[scaling] correct scaling root selectors
This commit is contained in:
parent
8562f46186
commit
ee1ca73fb2
|
@ -1,9 +1,19 @@
|
||||||
|
|
||||||
function checkScaling() {
|
function checkScaling() {
|
||||||
var str_mq_150 = "screen and (-webkit-min-device-pixel-ratio: 1.5) and (-webkit-max-device-pixel-ratio: 1.9), " +
|
var matches = {
|
||||||
"screen and (min-resolution: 1.5dppx) and (max-resolution: 1.9dppx)";
|
'pixel-ratio__1_25': "screen and (-webkit-min-device-pixel-ratio: 1.25) and (-webkit-max-device-pixel-ratio: 1.49), " +
|
||||||
if ( window.matchMedia(str_mq_150).matches ) {
|
"screen and (min-resolution: 1.25dppx) and (max-resolution: 1.49dppx)",
|
||||||
document.body.classList.add('pixel-ratio__1_5');
|
'pixel-ratio__1_5': "screen and (-webkit-min-device-pixel-ratio: 1.5) and (-webkit-max-device-pixel-ratio: 1.74), " +
|
||||||
|
"screen and (min-resolution: 1.5dppx) and (max-resolution: 1.74dppx)",
|
||||||
|
'pixel-ratio__1_75': "screen and (-webkit-min-device-pixel-ratio: 1.75) and (-webkit-max-device-pixel-ratio: 1.99), " +
|
||||||
|
"screen and (min-resolution: 1.75dppx) and (max-resolution: 1.99dppx)",
|
||||||
|
};
|
||||||
|
|
||||||
|
for (var c in matches) {
|
||||||
|
if ( window.matchMedia(matches[c]).matches ) {
|
||||||
|
document.body.classList.add(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !window.matchMedia("screen and (-webkit-device-pixel-ratio: 1.5)," +
|
if ( !window.matchMedia("screen and (-webkit-device-pixel-ratio: 1.5)," +
|
||||||
|
|
|
@ -136,29 +136,56 @@ var utils = new(function() {
|
||||||
scale = window.AscCommon.checkDeviceScale();
|
scale = window.AscCommon.checkDeviceScale();
|
||||||
AscCommon.correctApplicationScale(scale);
|
AscCommon.correctApplicationScale(scale);
|
||||||
} else {
|
} else {
|
||||||
var str_mq_150 = "screen and (-webkit-min-device-pixel-ratio: 1.5) and (-webkit-max-device-pixel-ratio: 1.9), " +
|
var str_mq_125 = "screen and (-webkit-min-device-pixel-ratio: 1.25) and (-webkit-max-device-pixel-ratio: 1.49), " +
|
||||||
"screen and (min-resolution: 1.5dppx) and (max-resolution: 1.9dppx)";
|
"screen and (min-resolution: 1.25dppx) and (max-resolution: 1.49dppx)";
|
||||||
|
var str_mq_150 = "screen and (-webkit-min-device-pixel-ratio: 1.5) and (-webkit-max-device-pixel-ratio: 1.74), " +
|
||||||
|
"screen and (min-resolution: 1.5dppx) and (max-resolution: 1.74dppx)";
|
||||||
|
var str_mq_175 = "screen and (-webkit-min-device-pixel-ratio: 1.75) and (-webkit-max-device-pixel-ratio: 1.99), " +
|
||||||
|
"screen and (min-resolution: 1.75dppx) and (max-resolution: 1.99dppx)";
|
||||||
var str_mq_200 = "screen and (-webkit-min-device-pixel-ratio: 2), " +
|
var str_mq_200 = "screen and (-webkit-min-device-pixel-ratio: 2), " +
|
||||||
"screen and (min-resolution: 2dppx), screen and (min-resolution: 192dpi)";
|
"screen and (min-resolution: 2dppx), screen and (min-resolution: 192dpi)";
|
||||||
|
|
||||||
|
if ( window.matchMedia(str_mq_125).matches ) {
|
||||||
|
scale.devicePixelRatio = 1.5;
|
||||||
|
} else
|
||||||
if ( window.matchMedia(str_mq_150).matches ) {
|
if ( window.matchMedia(str_mq_150).matches ) {
|
||||||
scale.devicePixelRatio = 1.5;
|
scale.devicePixelRatio = 1.5;
|
||||||
} else
|
} else
|
||||||
|
if ( window.matchMedia(str_mq_175).matches ) {
|
||||||
|
scale.devicePixelRatio = 1.75;
|
||||||
|
} else
|
||||||
if ( window.matchMedia(str_mq_200).matches )
|
if ( window.matchMedia(str_mq_200).matches )
|
||||||
scale.devicePixelRatio = 2;
|
scale.devicePixelRatio = 2;
|
||||||
else scale.devicePixelRatio = 1;
|
else scale.devicePixelRatio = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $root = $(document.body);
|
var $root = $(document.body);
|
||||||
if ( scale.devicePixelRatio < 1.5 ) {
|
var classes = document.body.className;
|
||||||
$root.removeClass('pixel-ratio__1_5 pixel-ratio__2');
|
var clear_list = classes.replace(/pixel-ratio__[\w-]+/gi,'').trim();
|
||||||
|
if ( scale.devicePixelRatio < 1.25 ) {
|
||||||
|
if ( /pixel-ratio__/.test(classes) ) {
|
||||||
|
document.body.className = clear_list;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
if ( !(scale.devicePixelRatio < 1.5) && scale.devicePixelRatio < 2 ) {
|
if ( scale.devicePixelRatio < 1.5 ) {
|
||||||
$root.removeClass('pixel-ratio__2');
|
if ( !/pixel-ratio__1_25/.test(classes) ) {
|
||||||
$root.addClass('pixel-ratio__1_5');
|
document.body.className = clear_list + ' pixel-ratio__1_25';
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if ( scale.devicePixelRatio < 1.75 ) {
|
||||||
|
if ( !/pixel-ratio__1_5/.test(classes) ) {
|
||||||
|
document.body.className = clear_list + ' pixel-ratio__1_5';
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if ( !(scale.devicePixelRatio < 1.75) && scale.devicePixelRatio < 2 ) {
|
||||||
|
if ( !/pixel-ratio__1_75/.test(classes) ) {
|
||||||
|
document.body.className = clear_list + ' pixel-ratio__1_75';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$root.addClass('pixel-ratio__2');
|
$root.addClass('pixel-ratio__2');
|
||||||
$root.removeClass('pixel-ratio__1_5');
|
if ( !/pixel-ratio__2/.test(classes) ) {
|
||||||
|
document.body.className = clear_list + ' pixel-ratio__2';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
me.zoom = scale.correct ? scale.zoom : 1;
|
me.zoom = scale.correct ? scale.zoom : 1;
|
||||||
|
|
Loading…
Reference in a new issue