Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recalculate original state when resize() was called #188

Merged
merged 1 commit into from
Nov 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/shadow-viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -124,8 +127,7 @@ ShadowViewport.prototype.processCTM = function() {
this.originalState.x = newCTM.e
this.originalState.y = newCTM.f
Copy link
Contributor Author

@kevinlaw91 kevinlaw91 Sep 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is only used by ShadowViewport.prototype.init(). So i moved it out and place it after calling processCTM() in init().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will allow reuse of processCTM() in SvgPanZoom.prototype.resize()


// Update viewport CTM and cache zoom and pan
this.setCTM(newCTM);
return newCTM
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/svg-pan-zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down