From 39811d9300d9dc91a66d4b2b8645fd1cd315c2e0 Mon Sep 17 00:00:00 2001 From: ronnymikalsen Date: Thu, 4 Feb 2021 12:24:01 +0100 Subject: [PATCH] fix: draw the level based on pixel density ratio --- src/tiledimage.js | 4 ++-- src/viewer.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tiledimage.js b/src/tiledimage.js index 74ffacef..ccc51601 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -1018,7 +1018,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag ); var currentZeroRatio = this.viewport.deltaPixelsFromPointsNoRotate( this.source.getPixelRatio(0), true).x * - this._scaleSpring.current.value; + this._scaleSpring.current.value * $.pixelDensityRatio; var highestLevel = Math.min( Math.abs(this.source.maxLevel), Math.abs(Math.floor( @@ -1082,7 +1082,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag var currentRenderPixelRatio = viewport.deltaPixelsFromPointsNoRotate( this.source.getPixelRatio(level), true - ).x * this._scaleSpring.current.value; + ).x * this._scaleSpring.current.value * $.pixelDensityRatio; if (level === lowestLevel || (!haveDrawn && currentRenderPixelRatio >= this.minPixelRatio)) { diff --git a/src/viewer.js b/src/viewer.js index b5b24318..ff958e06 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -401,6 +401,13 @@ $.Viewer = function( options ) { debugGridColor: this.debugGridColor }); + function resize() { + console.log("Windows is resized..."); + _this.world.resetItems(); + _this.forceRedraw(); + } + $.addEvent( window, 'resize', resize ); + // Overlay container this.overlaysContainer = $.makeNeutralElement( "div" ); this.canvas.appendChild( this.overlaysContainer );