diff --git a/src/shadow-viewport.js b/src/shadow-viewport.js index 5697084..7b84ff7 100644 --- a/src/shadow-viewport.js +++ b/src/shadow-viewport.js @@ -31,7 +31,10 @@ ShadowViewport.prototype.init = function(viewport, options) { this.cacheViewBox() // Process CTM - this.processCTM() + var newCTM = this.processCTM() + + // Update viewport CTM and cache zoom and pan + this.setCTM(newCTM) // Update CTM in this frame this.updateCTM() @@ -124,8 +127,7 @@ ShadowViewport.prototype.processCTM = function() { this.originalState.x = newCTM.e this.originalState.y = newCTM.f - // Update viewport CTM and cache zoom and pan - this.setCTM(newCTM); + return newCTM } /** diff --git a/src/svg-pan-zoom.js b/src/svg-pan-zoom.js index 3d2fcc5..1d12092 100644 --- a/src/svg-pan-zoom.js +++ b/src/svg-pan-zoom.js @@ -569,6 +569,12 @@ SvgPanZoom.prototype.resize = function() { this.width = boundingClientRectNormalized.width this.height = boundingClientRectNormalized.height + // Recalculate original state + var viewport = this.viewport + viewport.options.width = this.width + viewport.options.height = this.height + viewport.processCTM() + // Reposition control icons by re-enabling them if (this.options.controlIconsEnabled) { this.getPublicInstance().disableControlIcons()