feat: add DPR
This commit is contained in:
parent
2329f5235a
commit
cd1c0651eb
1 changed files with 8 additions and 3 deletions
|
@ -5,14 +5,16 @@
|
|||
|
||||
let screenResolution = '... x ...';
|
||||
let windowResolution = '';
|
||||
let dpr = "1";
|
||||
|
||||
function updateResolution() {
|
||||
const realWidth = Math.round(screen.width);
|
||||
const realHeight = Math.round(screen.height);
|
||||
const realWidth = Math.round(screen.width) * window.devicePixelRatio;
|
||||
const realHeight = Math.round(screen.height) * window.devicePixelRatio;
|
||||
const windowWidth = Math.round(window.innerWidth * window.devicePixelRatio);
|
||||
const windowHeight = Math.round(window.innerHeight * window.devicePixelRatio);
|
||||
screenResolution = `${realWidth} x ${realHeight}`;
|
||||
windowResolution = `${windowWidth} x ${windowHeight}`;
|
||||
dpr = String(Math.round(window.devicePixelRatio * 100) / 100);
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
|
@ -33,6 +35,9 @@
|
|||
<div class="value">{windowResolution}</div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if dpr !== "1"}
|
||||
<div class="dpr">{$i18n.t("Device Pixel Ratio")}: {dpr}</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -45,7 +50,7 @@
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
.window {
|
||||
.window, .dpr {
|
||||
margin-top: calc(1em / 0.8);
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue