Add asserts on this.viewer.

This commit is contained in:
Antoine Vandecreme 2016-04-21 10:57:39 -04:00
parent b1a0abd104
commit 65a95d4a49

View File

@ -1277,8 +1277,10 @@ $.Viewport.prototype = {
* @returns {OpenSeadragon.Point}
*/
windowToImageCoordinates: function(pixel) {
$.console.assert(this.viewer,
"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");
var viewerCoordinates = pixel.minus(
OpenSeadragon.getElementPosition( this.viewer.element ));
$.getElementPosition(this.viewer.element));
return this.viewerElementToImageCoordinates(viewerCoordinates);
},
@ -1289,9 +1291,11 @@ $.Viewport.prototype = {
* @returns {OpenSeadragon.Point}
*/
imageToWindowCoordinates: function(pixel) {
$.console.assert(this.viewer,
"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");
var viewerCoordinates = this.imageToViewerElementCoordinates(pixel);
return viewerCoordinates.plus(
OpenSeadragon.getElementPosition( this.viewer.element ));
$.getElementPosition(this.viewer.element));
},
/**
@ -1348,8 +1352,10 @@ $.Viewport.prototype = {
* @returns {OpenSeadragon.Point}
*/
windowToViewportCoordinates: function(pixel) {
$.console.assert(this.viewer,
"[Viewport.windowToViewportCoordinates] the viewport must have a viewer.");
var viewerCoordinates = pixel.minus(
OpenSeadragon.getElementPosition( this.viewer.element ));
$.getElementPosition(this.viewer.element));
return this.viewerElementToViewportCoordinates(viewerCoordinates);
},
@ -1359,9 +1365,11 @@ $.Viewport.prototype = {
* @returns {OpenSeadragon.Point}
*/
viewportToWindowCoordinates: function(point) {
$.console.assert(this.viewer,
"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");
var viewerCoordinates = this.viewportToViewerElementCoordinates(point);
return viewerCoordinates.plus(
OpenSeadragon.getElementPosition( this.viewer.element ));
$.getElementPosition(this.viewer.element));
},
/**