From c410b82e65ede9a733927b7c387069010182cebe Mon Sep 17 00:00:00 2001 From: ronnymikalsen Date: Thu, 4 Feb 2021 13:39:26 +0100 Subject: [PATCH] fix: refresh $.pixelDensityRatio --- src/viewer.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/viewer.js b/src/viewer.js index ff958e06..03b018bc 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -403,6 +403,21 @@ $.Viewer = function( options ) { function resize() { console.log("Windows is resized..."); + $.pixelDensityRatio = (function () { + if ( $.supportsCanvas ) { + var context = document.createElement('canvas').getContext('2d'); + var devicePixelRatio = window.devicePixelRatio || 1; + var backingStoreRatio = context.webkitBackingStorePixelRatio || + context.mozBackingStorePixelRatio || + context.msBackingStorePixelRatio || + context.oBackingStorePixelRatio || + context.backingStorePixelRatio || 1; + return Math.max(devicePixelRatio, 1) / backingStoreRatio; + } else { + return 1; + } + }()); + console.log("$.pixelDensityRatio", $.pixelDensityRatio); _this.world.resetItems(); _this.forceRedraw(); }