mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-19 17:21:50 +03:00
Support removal of base layer.
This commit is contained in:
parent
1c1cd0dc4d
commit
53ec6889e0
@ -1181,6 +1181,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Remove a layer. If there is only one layer, close the viewer.
|
||||||
* @function
|
* @function
|
||||||
* @param {OpenSeadragon.Drawer} drawer The underlying drawer of the layer
|
* @param {OpenSeadragon.Drawer} drawer The underlying drawer of the layer
|
||||||
* to remove
|
* to remove
|
||||||
@ -1193,7 +1194,14 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
if ( index === 0 ) {
|
if ( index === 0 ) {
|
||||||
throw new Error( "Cannot remove base layer." );
|
if ( THIS[ this.hash ].sequenced ) {
|
||||||
|
throw new Error( "Cannot remove base layer when in sequence mode." );
|
||||||
|
}
|
||||||
|
if ( this.drawers.length === 1 ) {
|
||||||
|
this.close();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
this.drawer = this.drawers[ 1 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.drawers.splice( index, 1 );
|
this.drawers.splice( index, 1 );
|
||||||
|
@ -162,11 +162,11 @@
|
|||||||
var options = {
|
var options = {
|
||||||
tileSource: {
|
tileSource: {
|
||||||
type: 'legacy-image-pyramid',
|
type: 'legacy-image-pyramid',
|
||||||
levels: [ {
|
levels: [{
|
||||||
url: "data/A.png",
|
url: "data/A.png",
|
||||||
width: 1000,
|
width: 1000,
|
||||||
height: 1000
|
height: 1000
|
||||||
} ]
|
}]
|
||||||
},
|
},
|
||||||
level: 0
|
level: 0
|
||||||
};
|
};
|
||||||
@ -180,12 +180,19 @@
|
|||||||
equal( viewer.drawer, aDrawer, "Viewer.drawer should be set to aDrawer." );
|
equal( viewer.drawer, aDrawer, "Viewer.drawer should be set to aDrawer." );
|
||||||
viewer.setLayerLevel( aDrawer, 1 );
|
viewer.setLayerLevel( aDrawer, 1 );
|
||||||
equal( viewer.drawer, testPatternDrawer, "Viewer.drawer should be set back to testPatternDrawer." );
|
equal( viewer.drawer, testPatternDrawer, "Viewer.drawer should be set back to testPatternDrawer." );
|
||||||
start( );
|
|
||||||
} );
|
viewer.removeLayer( viewer.drawer );
|
||||||
|
equal( viewer.drawer, aDrawer, "Viewer.drawer must be reassigned when removing base layer." );
|
||||||
|
|
||||||
|
viewer.removeLayer( viewer.drawer );
|
||||||
|
ok( !viewer.isOpen(), "Viewer should be closed when removing last layer." );
|
||||||
|
|
||||||
|
start();
|
||||||
|
});
|
||||||
viewer.addLayer( options );
|
viewer.addLayer( options );
|
||||||
} );
|
});
|
||||||
viewer.open( '/test/data/testpattern.dzi' );
|
viewer.open( '/test/data/testpattern.dzi' );
|
||||||
} );
|
});
|
||||||
|
|
||||||
asyncTest( 'Layers and sequences', function() {
|
asyncTest( 'Layers and sequences', function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
@ -209,37 +216,37 @@
|
|||||||
// }]}] );
|
// }]}] );
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
viewer = OpenSeadragon( {
|
viewer = OpenSeadragon({
|
||||||
id: 'layersexample',
|
id: 'layersexample',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
springStiffness: 100, // Faster animation = faster tests
|
springStiffness: 100, // Faster animation = faster tests
|
||||||
tileSources: [ {
|
tileSources: [{
|
||||||
type: 'legacy-image-pyramid',
|
type: 'legacy-image-pyramid',
|
||||||
levels: [ {
|
levels: [{
|
||||||
url: "data/A.png",
|
url: "data/A.png",
|
||||||
width: 1000,
|
width: 1000,
|
||||||
height: 1000
|
height: 1000
|
||||||
} ]
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'legacy-image-pyramid',
|
type: 'legacy-image-pyramid',
|
||||||
levels: [ {
|
levels: [{
|
||||||
url: "data/BBlue.png",
|
url: "data/BBlue.png",
|
||||||
width: 1000,
|
width: 1000,
|
||||||
height: 1000
|
height: 1000
|
||||||
} ] } ]
|
}]
|
||||||
|
}]
|
||||||
} );
|
});
|
||||||
// End workaround
|
// End workaround
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
tileSource: {
|
tileSource: {
|
||||||
type: 'legacy-image-pyramid',
|
type: 'legacy-image-pyramid',
|
||||||
levels: [ {
|
levels: [{
|
||||||
url: "data/CCyan.png",
|
url: "data/CCyan.png",
|
||||||
width: 1000,
|
width: 1000,
|
||||||
height: 1000
|
height: 1000
|
||||||
} ]
|
}]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user