mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Add Viewer.addSimpleImage method. Fix #818
This commit is contained in:
parent
8d453b5755
commit
ea6addb4c8
@ -1393,6 +1393,31 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a simple image to the viewer.
|
||||
* The options are the same than {@link OpenSeadragon.Viewer#addTiledImage}
|
||||
* except for options.tileSource which is replaced by options.url.
|
||||
* @function
|
||||
* @param {Object} options - See {@link OpenSeadragon.Viewer#addTiledImage}
|
||||
* for all the options
|
||||
* @param {String} options.url - The URL of the image to add.
|
||||
* @fires OpenSeadragon.World.event:add-item
|
||||
* @fires OpenSeadragon.Viewer.event:add-item-failed
|
||||
*/
|
||||
addSimpleImage: function(options) {
|
||||
$.console.assert(options, "[Viewer.addSimpleImage] options is required");
|
||||
$.console.assert(options.url, "[Viewer.addSimpleImage] options.url is required");
|
||||
|
||||
var opts = $.extend({}, options, {
|
||||
tileSource: {
|
||||
type: 'image',
|
||||
url: options.url
|
||||
}
|
||||
});
|
||||
delete opts.url;
|
||||
this.addTiledImage(opts);
|
||||
},
|
||||
|
||||
// deprecated
|
||||
addLayer: function( options ) {
|
||||
var _this = this;
|
||||
|
@ -189,4 +189,22 @@
|
||||
]);
|
||||
});
|
||||
|
||||
asyncTest('Viewer.addSimpleImage', function() {
|
||||
viewer.addHandler("open", function openHandler() {
|
||||
viewer.removeHandler("open", openHandler);
|
||||
|
||||
viewer.world.addHandler('add-item', function itemAdded(event) {
|
||||
viewer.world.removeHandler('add-item', itemAdded);
|
||||
equal(event.item.opacity, 0.5, 'Opacity option not set using addSimpleImage');
|
||||
start();
|
||||
});
|
||||
|
||||
viewer.addSimpleImage({
|
||||
url: '/test/data/A.png',
|
||||
opacity: 0.5
|
||||
});
|
||||
});
|
||||
viewer.open('/test/data/testpattern.dzi');
|
||||
});
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user