Moved Viewport.goHome to Viewer.goHome.

This commit is contained in:
Ian Gilman 2014-08-12 16:44:53 -07:00
parent 66b8d7e191
commit 5c7c1d5b6c
6 changed files with 51 additions and 41 deletions

View File

@ -333,7 +333,7 @@ $.Viewer = function( options ) {
_this.viewport.applyConstraints();
return false;
case 48://0|)
_this.viewport.goHome();
_this.goHome();
_this.viewport.applyConstraints();
return false;
case 119://w
@ -622,6 +622,28 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
this.element = null;
},
/**
* @function
* @param {Boolean} immediately
* @fires OpenSeadragon.Viewer.event:home
*/
goHome: function(immediately) {
/**
* Raised when the "home" operation occurs (see {@link OpenSeadragon.Viewport#goHome}).
*
* @event home
* @memberof OpenSeadragon.Viewer
* @type {object}
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
* @property {Boolean} immediately
* @property {?Object} userData - Arbitrary subscriber-defined object.
*/
this.raiseEvent( 'home', {
immediately: immediately
});
this.viewport.fitBounds( this.world.getHomeBounds(), immediately );
},
/**
* @function
@ -1929,6 +1951,7 @@ function openTileSource( viewer, source, options ) {
});
_this.world.addItem( tiledImage );
_this.goHome( true );
// Now that we have a drawer, see if it supports rotate. If not we need to remove the rotate buttons
if (!_this.drawer.canRotate()) {
@ -2793,9 +2816,7 @@ function lightUp() {
function onHome() {
if ( this.viewport ) {
this.viewport.goHome();
}
this.goHome();
}

View File

@ -105,7 +105,6 @@ $.Viewport = function( options ) {
});
this.resetContentSize( this.contentSize );
this.goHome( true );
this.update();
};
@ -178,26 +177,15 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
/**
* @function
* @param {Boolean} immediately
* @fires OpenSeadragon.Viewer.event:home
* @private
*/
goHome: function( immediately ) {
$.console.error("[Viewport.goHome] this function is deprecated; use Viewer.goHome instead");
if( this.viewer ){
/**
* Raised when the "home" operation occurs (see {@link OpenSeadragon.Viewport#goHome}).
*
* @event home
* @memberof OpenSeadragon.Viewer
* @type {object}
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
* @property {Boolean} immediately
* @property {?Object} userData - Arbitrary subscriber-defined object.
*/
this.viewer.raiseEvent( 'home', {
immediately: immediately
});
this.viewer.goHome(immediately);
}
return this.fitBounds( this.getHomeBounds(), immediately );
return this;
},
/**

View File

@ -133,7 +133,7 @@
};
viewer.addHandler('animation-finish', homeHandler);
viewport.goHome(true);
viewer.goHome(true);
}
viewer.addHandler("open", opener);

View File

@ -38,6 +38,7 @@
var addLayerHandler = function( event ) {
if ( event.options === options ) {
self.viewer.removeHandler( "add-layer", addLayerHandler );
self.viewer.goHome();
}
};
this.viewer.addHandler( "add-layer", addLayerHandler );

View File

@ -105,7 +105,7 @@
}
function goHome() {
_viewer.viewport.goHome();
_viewer.goHome();
}
</script>

View File

@ -270,7 +270,7 @@
waitForViewer( function() {
checkOverlayPosition( "after zoom and pan using image coordinates" );
viewer.viewport.goHome();
viewer.goHome();
waitForViewer( function() {
checkOverlayPosition( "after goHome using image coordinates" );
start();
@ -333,7 +333,7 @@
waitForViewer( function() {
checkOverlayPosition( "after zoom and pan using viewport coordinates" );
viewer.viewport.goHome();
viewer.goHome();
waitForViewer( function() {
checkOverlayPosition( "after goHome using viewport coordinates" );
start();