From 925ba8a78e41452e0af0d00c31f8a97f322f272e Mon Sep 17 00:00:00 2001 From: Antoine Vandecreme Date: Sat, 13 Feb 2016 11:20:34 -0500 Subject: [PATCH] Rename viewport.contentAspectX to viewport.contentAspectRatio. Remove viewport.contentAspectY. --- src/viewport.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/viewport.js b/src/viewport.js index 81bcbb3b..ce22e6c0 100644 --- a/src/viewport.js +++ b/src/viewport.js @@ -135,7 +135,7 @@ $.Viewport = function( options ) { this._oldZoom = this.zoomSpring.current.value; if (this.contentSize) { - this.resetContentSize( this.contentSize ); + this.resetContentSize(this.contentSize); } else { this._setContentBounds(new $.Rect(0, 0, 1, 1), 1); } @@ -153,7 +153,7 @@ $.Viewport.prototype = { * @return {OpenSeadragon.Viewport} Chainable. * @fires OpenSeadragon.Viewer.event:reset-size */ - resetContentSize: function( contentSize ){ + resetContentSize: function(contentSize) { $.console.assert(contentSize, "[Viewport.resetContentSize] contentSize is required"); $.console.assert(contentSize instanceof $.Point, "[Viewport.resetContentSize] contentSize must be an OpenSeadragon.Point"); $.console.assert(contentSize.x > 0, "[Viewport.resetContentSize] contentSize.x must be greater than 0"); @@ -184,8 +184,7 @@ $.Viewport.prototype = { this._contentBounds = bounds.rotate(this.degrees).getBoundingBox(); this.contentSize = this._contentBounds.getSize().times(contentFactor); - this.contentAspectX = this.contentSize.x / this.contentSize.y; - this.contentAspectY = this.contentSize.y / this.contentSize.x; + this._contentAspectRatio = this.contentSize.x / this.contentSize.y; if (this.viewer) { /** @@ -222,7 +221,7 @@ $.Viewport.prototype = { return this.defaultZoomLevel; } - var aspectFactor = this.contentAspectX / this.getAspectRatio(); + var aspectFactor = this._contentAspectRatio / this.getAspectRatio(); var output; if (this.homeFillsViewer) { // fill the viewer and clip the image output = aspectFactor >= 1 ? aspectFactor : 1; @@ -1074,8 +1073,9 @@ $.Viewport.prototype = { // private _viewportToImageDelta: function( viewerX, viewerY ) { var scale = this._contentBounds.width; - return new $.Point(viewerX * (this.contentSize.x / scale), - viewerY * ((this.contentSize.y * this.contentAspectX) / scale)); + return new $.Point( + viewerX * this.contentSize.x / scale, + viewerY * this.contentSize.x / scale); }, /** @@ -1105,8 +1105,9 @@ $.Viewport.prototype = { // private _imageToViewportDelta: function( imageX, imageY ) { var scale = this._contentBounds.width; - return new $.Point((imageX / this.contentSize.x) * scale, - (imageY / this.contentSize.y / this.contentAspectX) * scale); + return new $.Point( + imageX / this.contentSize.x * scale, + imageY / this.contentSize.x * scale); }, /**