mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Add getCompletionCallback method.
This commit is contained in:
parent
4c1d0f9a4c
commit
be657c0b3d
@ -976,11 +976,16 @@ function onTileLoad( tiledImage, tile, time, image ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setTileLoaded(tiledImage, tile, image, cutoff) {
|
function setTileLoaded(tiledImage, tile, image, cutoff) {
|
||||||
tiledImage.viewer.raiseEvent("tile-loaded", {
|
var increment = 0;
|
||||||
tile: tile,
|
|
||||||
tiledImage: tiledImage,
|
function getCompletionCallback() {
|
||||||
image: image
|
increment++;
|
||||||
});
|
return completionCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
function completionCallback() {
|
||||||
|
increment--;
|
||||||
|
if (increment === 0) {
|
||||||
tile.loading = false;
|
tile.loading = false;
|
||||||
tile.loaded = true;
|
tile.loaded = true;
|
||||||
tiledImage._tileCache.cacheTile({
|
tiledImage._tileCache.cacheTile({
|
||||||
@ -990,6 +995,33 @@ function setTileLoaded(tiledImage, tile, image, cutoff) {
|
|||||||
tiledImage: tiledImage
|
tiledImage: tiledImage
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered when a tile has just been loaded in memory. That means that the
|
||||||
|
* image has been downloaded and can be modified asynchronously before being
|
||||||
|
* drawn to the canvas.
|
||||||
|
*
|
||||||
|
* @event tile-loaded
|
||||||
|
* @memberof OpenSeadragon.Viewer
|
||||||
|
* @type {object}
|
||||||
|
* @property {Image} image - The image of the tile.
|
||||||
|
* @property {OpenSeadragon.TiledImage} tiledImage - The tiled image of the loaded tile.
|
||||||
|
* @property {OpenSeadragon.Tile} tile - The tile which has been loaded.
|
||||||
|
* @property {function} getCompletionCallback - A function giving a callback to call
|
||||||
|
* when the asynchronous processing of the image is done. The image will be
|
||||||
|
* marked as entirely loaded once the callback has been called as many times as
|
||||||
|
* getCompletionCallback
|
||||||
|
*/
|
||||||
|
tiledImage.viewer.raiseEvent("tile-loaded", {
|
||||||
|
tile: tile,
|
||||||
|
tiledImage: tiledImage,
|
||||||
|
image: image,
|
||||||
|
getCompletionCallback: getCompletionCallback
|
||||||
|
});
|
||||||
|
// In case the completion callback is never called, we at least force it once.
|
||||||
|
getCompletionCallback()();
|
||||||
|
}
|
||||||
|
|
||||||
function positionTile( tile, overlap, viewport, viewportCenter, levelVisibility, tiledImage ){
|
function positionTile( tile, overlap, viewport, viewportCenter, levelVisibility, tiledImage ){
|
||||||
var boundsTL = tile.bounds.getTopLeft();
|
var boundsTL = tile.bounds.getTopLeft();
|
||||||
|
Loading…
Reference in New Issue
Block a user