mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-19 09:11:45 +03:00
Add asserts on this.viewer.
This commit is contained in:
parent
b1a0abd104
commit
65a95d4a49
@ -1134,7 +1134,7 @@ $.Viewport.prototype = {
|
||||
if (this.viewer) {
|
||||
var count = this.viewer.world.getItemCount();
|
||||
if (count > 1) {
|
||||
$.console.error('[Viewport.imageToViewportCoordinates] is not accurate ' +
|
||||
$.console.error('[Viewport.imageToViewportCoordinates] is not accurate ' +
|
||||
'with multi-image; use TiledImage.imageToViewportCoordinates instead.');
|
||||
} else if (count === 1) {
|
||||
// It is better to use TiledImage.viewportToImageCoordinates
|
||||
@ -1276,10 +1276,12 @@ $.Viewport.prototype = {
|
||||
* @param {OpenSeadragon.Point} pixel
|
||||
* @returns {OpenSeadragon.Point}
|
||||
*/
|
||||
windowToImageCoordinates: function( pixel ) {
|
||||
windowToImageCoordinates: function(pixel) {
|
||||
$.console.assert(this.viewer,
|
||||
"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");
|
||||
var viewerCoordinates = pixel.minus(
|
||||
OpenSeadragon.getElementPosition( this.viewer.element ));
|
||||
return this.viewerElementToImageCoordinates( viewerCoordinates );
|
||||
$.getElementPosition(this.viewer.element));
|
||||
return this.viewerElementToImageCoordinates(viewerCoordinates);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1288,10 +1290,12 @@ $.Viewport.prototype = {
|
||||
* @param {OpenSeadragon.Point} pixel
|
||||
* @returns {OpenSeadragon.Point}
|
||||
*/
|
||||
imageToWindowCoordinates: function( pixel ) {
|
||||
var viewerCoordinates = this.imageToViewerElementCoordinates( pixel );
|
||||
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));
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1347,10 +1351,12 @@ $.Viewport.prototype = {
|
||||
* @param {OpenSeadragon.Point} pixel
|
||||
* @returns {OpenSeadragon.Point}
|
||||
*/
|
||||
windowToViewportCoordinates: function( pixel ) {
|
||||
windowToViewportCoordinates: function(pixel) {
|
||||
$.console.assert(this.viewer,
|
||||
"[Viewport.windowToViewportCoordinates] the viewport must have a viewer.");
|
||||
var viewerCoordinates = pixel.minus(
|
||||
OpenSeadragon.getElementPosition( this.viewer.element ));
|
||||
return this.viewerElementToViewportCoordinates( viewerCoordinates );
|
||||
$.getElementPosition(this.viewer.element));
|
||||
return this.viewerElementToViewportCoordinates(viewerCoordinates);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1358,10 +1364,12 @@ $.Viewport.prototype = {
|
||||
* @param {OpenSeadragon.Point} point
|
||||
* @returns {OpenSeadragon.Point}
|
||||
*/
|
||||
viewportToWindowCoordinates: function( point ) {
|
||||
var viewerCoordinates = this.viewportToViewerElementCoordinates( 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));
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1380,7 +1388,7 @@ $.Viewport.prototype = {
|
||||
if (this.viewer) {
|
||||
var count = this.viewer.world.getItemCount();
|
||||
if (count > 1) {
|
||||
$.console.error('[Viewport.viewportToImageZoom] is not ' +
|
||||
$.console.error('[Viewport.viewportToImageZoom] is not ' +
|
||||
'accurate with multi-image.');
|
||||
} else if (count === 1) {
|
||||
// It is better to use TiledImage.viewportToImageZoom
|
||||
|
Loading…
x
Reference in New Issue
Block a user