Rename viewport.contentAspectX to viewport.contentAspectRatio. Remove viewport.contentAspectY.

This commit is contained in:
Antoine Vandecreme 2016-02-13 11:20:34 -05:00
parent 4634d90715
commit 925ba8a78e

View File

@ -135,7 +135,7 @@ $.Viewport = function( options ) {
this._oldZoom = this.zoomSpring.current.value; this._oldZoom = this.zoomSpring.current.value;
if (this.contentSize) { if (this.contentSize) {
this.resetContentSize( this.contentSize ); this.resetContentSize(this.contentSize);
} else { } else {
this._setContentBounds(new $.Rect(0, 0, 1, 1), 1); this._setContentBounds(new $.Rect(0, 0, 1, 1), 1);
} }
@ -153,7 +153,7 @@ $.Viewport.prototype = {
* @return {OpenSeadragon.Viewport} Chainable. * @return {OpenSeadragon.Viewport} Chainable.
* @fires OpenSeadragon.Viewer.event:reset-size * @fires OpenSeadragon.Viewer.event:reset-size
*/ */
resetContentSize: function( contentSize ){ resetContentSize: function(contentSize) {
$.console.assert(contentSize, "[Viewport.resetContentSize] contentSize is required"); $.console.assert(contentSize, "[Viewport.resetContentSize] contentSize is required");
$.console.assert(contentSize instanceof $.Point, "[Viewport.resetContentSize] contentSize must be an OpenSeadragon.Point"); $.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"); $.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._contentBounds = bounds.rotate(this.degrees).getBoundingBox();
this.contentSize = this._contentBounds.getSize().times(contentFactor); this.contentSize = this._contentBounds.getSize().times(contentFactor);
this.contentAspectX = this.contentSize.x / this.contentSize.y; this._contentAspectRatio = this.contentSize.x / this.contentSize.y;
this.contentAspectY = this.contentSize.y / this.contentSize.x;
if (this.viewer) { if (this.viewer) {
/** /**
@ -222,7 +221,7 @@ $.Viewport.prototype = {
return this.defaultZoomLevel; return this.defaultZoomLevel;
} }
var aspectFactor = this.contentAspectX / this.getAspectRatio(); var aspectFactor = this._contentAspectRatio / this.getAspectRatio();
var output; var output;
if (this.homeFillsViewer) { // fill the viewer and clip the image if (this.homeFillsViewer) { // fill the viewer and clip the image
output = aspectFactor >= 1 ? aspectFactor : 1; output = aspectFactor >= 1 ? aspectFactor : 1;
@ -1074,8 +1073,9 @@ $.Viewport.prototype = {
// private // private
_viewportToImageDelta: function( viewerX, viewerY ) { _viewportToImageDelta: function( viewerX, viewerY ) {
var scale = this._contentBounds.width; var scale = this._contentBounds.width;
return new $.Point(viewerX * (this.contentSize.x / scale), return new $.Point(
viewerY * ((this.contentSize.y * this.contentAspectX) / scale)); viewerX * this.contentSize.x / scale,
viewerY * this.contentSize.x / scale);
}, },
/** /**
@ -1105,8 +1105,9 @@ $.Viewport.prototype = {
// private // private
_imageToViewportDelta: function( imageX, imageY ) { _imageToViewportDelta: function( imageX, imageY ) {
var scale = this._contentBounds.width; var scale = this._contentBounds.width;
return new $.Point((imageX / this.contentSize.x) * scale, return new $.Point(
(imageY / this.contentSize.y / this.contentAspectX) * scale); imageX / this.contentSize.x * scale,
imageY / this.contentSize.x * scale);
}, },
/** /**