mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-20 09:41:45 +03:00
Add basic layers support
This commit is contained in:
parent
95c945ca8a
commit
58da998d75
@ -578,6 +578,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
|
|
||||||
this.source = null;
|
this.source = null;
|
||||||
this.drawer = null;
|
this.drawer = null;
|
||||||
|
this.drawers = [];
|
||||||
|
|
||||||
this.viewport = this.preserveViewport ? this.viewport : null;
|
this.viewport = this.preserveViewport ? this.viewport : null;
|
||||||
//this.profiler = null;
|
//this.profiler = null;
|
||||||
@ -1045,6 +1046,20 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @name OpenSeadragon.Viewer.prototype.addLayer
|
||||||
|
*/
|
||||||
|
addLayer: function( tileSource ) {
|
||||||
|
var drawer = new $.Drawer(
|
||||||
|
tileSource,
|
||||||
|
this.viewport,
|
||||||
|
this.canvas
|
||||||
|
);
|
||||||
|
this.drawers.push( drawer );
|
||||||
|
updateOnce( this );
|
||||||
|
return drawer.canvas;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
@ -1460,6 +1475,7 @@ function openTileSource( viewer, source ) {
|
|||||||
debugMode: _this.debugMode,
|
debugMode: _this.debugMode,
|
||||||
debugGridColor: _this.debugGridColor
|
debugGridColor: _this.debugGridColor
|
||||||
});
|
});
|
||||||
|
_this.drawers.push( _this.drawer );
|
||||||
|
|
||||||
//Instantiate a navigator if configured
|
//Instantiate a navigator if configured
|
||||||
if ( _this.showNavigator && !_this.collectionMode ){
|
if ( _this.showNavigator && !_this.collectionMode ){
|
||||||
@ -1929,7 +1945,7 @@ function updateOnce( viewer ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( animated ) {
|
if ( animated ) {
|
||||||
viewer.drawer.update();
|
updateDrawers( viewer );
|
||||||
if( viewer.navigator ){
|
if( viewer.navigator ){
|
||||||
viewer.navigator.update( viewer.viewport );
|
viewer.navigator.update( viewer.viewport );
|
||||||
}
|
}
|
||||||
@ -1943,8 +1959,8 @@ function updateOnce( viewer ) {
|
|||||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||||
*/
|
*/
|
||||||
viewer.raiseEvent( "animation" );
|
viewer.raiseEvent( "animation" );
|
||||||
} else if ( THIS[ viewer.hash ].forceRedraw || viewer.drawer.needsUpdate() ) {
|
} else if ( THIS[ viewer.hash ].forceRedraw || drawersNeedUpdate( viewer ) ) {
|
||||||
viewer.drawer.update();
|
updateDrawers( viewer );
|
||||||
if( viewer.navigator ){
|
if( viewer.navigator ){
|
||||||
viewer.navigator.update( viewer.viewport );
|
viewer.navigator.update( viewer.viewport );
|
||||||
}
|
}
|
||||||
@ -1998,6 +2014,18 @@ function resizeViewportAndRecenter( viewer, containerSize, oldBounds, oldCenter
|
|||||||
viewport.fitBounds( newBounds, true );
|
viewport.fitBounds( newBounds, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateDrawers( viewer ) {
|
||||||
|
viewer.drawers.forEach( function( drawer ) {
|
||||||
|
drawer.update();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawersNeedUpdate( viewer ) {
|
||||||
|
return viewer.drawers.some( function( drawer ) {
|
||||||
|
return drawer.needsUpdate();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Navigation Controls
|
// Navigation Controls
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user