mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 14:46:10 +03:00
Remove tile-drawn event and replace with tiled-image-drawn for webgl drawer, and update related tests.
This commit is contained in:
parent
2ec2c0f2c7
commit
24c4d2d2bc
@ -375,7 +375,8 @@ class Context2dDrawer extends $.DrawerBase{
|
||||
|
||||
if( this.viewer ){
|
||||
/**
|
||||
* Raised when a tile is drawn to the canvas
|
||||
* Raised when a tile is drawn to the canvas. Only valid for
|
||||
* context2d and html drawers.
|
||||
*
|
||||
* @event tile-drawn
|
||||
* @memberof OpenSeadragon.Viewer
|
||||
|
@ -145,7 +145,8 @@ class HTMLDrawer extends $.DrawerBase{
|
||||
|
||||
if( this.viewer ){
|
||||
/**
|
||||
* Raised when a tile is drawn to the canvas
|
||||
* Raised when a tile is drawn to the canvas. Only valid for
|
||||
* context2d and html drawers.
|
||||
*
|
||||
* @event tile-drawn
|
||||
* @memberof OpenSeadragon.Viewer
|
||||
|
@ -342,29 +342,24 @@ $.WebGLDrawer = class WebGLDrawer extends OpenSeadragon.DrawerBase{
|
||||
this._drawDebugInfo(tilesToDraw, tiledImage, strokeStyle, fillStyle);
|
||||
}
|
||||
|
||||
// TO DO: this is necessary for the tests to pass, but doesn't totally make sense for the webgl drawer.
|
||||
// Iterate over the tiles that were just drawn and fire the tile-drawn event
|
||||
for(let i = 0; i < tilesToDraw.length; i++){
|
||||
let tile = tilesToDraw[i].tile;
|
||||
|
||||
if( this.viewer ){
|
||||
/**
|
||||
* Raised when a tile is drawn to the canvas
|
||||
* Raised when a tiled image is drawn to the canvas. Only valid
|
||||
* for webgl drawer.
|
||||
*
|
||||
* @event tile-drawn
|
||||
* @event tiled-image-drawn
|
||||
* @memberof OpenSeadragon.Viewer
|
||||
* @type {object}
|
||||
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
||||
* @property {OpenSeadragon.TiledImage} tiledImage - Which TiledImage is being drawn.
|
||||
* @property {OpenSeadragon.Tile} tile
|
||||
* @property {Array} tiles - An array of Tile objects that were drawn.
|
||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||
*/
|
||||
this.viewer.raiseEvent( 'tile-drawn', {
|
||||
this.viewer.raiseEvent( 'tiled-image-drawn', {
|
||||
tiledImage: tiledImage,
|
||||
tile: tile
|
||||
tiles: tilesToDraw.map(info => info.tile),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
@ -80,12 +80,12 @@
|
||||
// The changeover will look better if we wait for the first tile to be drawn.
|
||||
var tileDrawnHandler = function(event) {
|
||||
if (event.tiledImage === fullImage) {
|
||||
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
||||
viewer.removeHandler('tiled-image-drawn', tileDrawnHandler);
|
||||
viewer.world.removeItem(standin);
|
||||
}
|
||||
};
|
||||
|
||||
viewer.addHandler('tile-drawn', tileDrawnHandler);
|
||||
viewer.addHandler('tiled-image-drawn', tileDrawnHandler);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -322,8 +322,8 @@
|
||||
height: 155
|
||||
} ]
|
||||
} );
|
||||
viewer.addOnceHandler('tile-drawn', function(event) {
|
||||
assert.ok(OpenSeadragon.isCanvasTainted(event.tile.getCanvasContext().canvas),
|
||||
viewer.addOnceHandler('tiled-image-drawn', function(event) {
|
||||
assert.ok(OpenSeadragon.isCanvasTainted(event.tiles[0].getCanvasContext().canvas),
|
||||
"Canvas should be tainted.");
|
||||
done();
|
||||
});
|
||||
@ -342,8 +342,8 @@
|
||||
height: 155
|
||||
} ]
|
||||
} );
|
||||
viewer.addOnceHandler('tile-drawn', function(event) {
|
||||
assert.ok(!OpenSeadragon.isCanvasTainted(event.tile.getCanvasContext().canvas),
|
||||
viewer.addOnceHandler('tiled-image-drawn', function(event) {
|
||||
assert.ok(!OpenSeadragon.isCanvasTainted(event.tiles[0].getCanvasContext().canvas),
|
||||
"Canvas should not be tainted.");
|
||||
done();
|
||||
});
|
||||
@ -366,8 +366,8 @@
|
||||
},
|
||||
crossOriginPolicy : false
|
||||
} );
|
||||
viewer.addOnceHandler('tile-drawn', function(event) {
|
||||
assert.ok(OpenSeadragon.isCanvasTainted(event.tile.getCanvasContext().canvas),
|
||||
viewer.addOnceHandler('tiled-image-drawn', function(event) {
|
||||
assert.ok(OpenSeadragon.isCanvasTainted(event.tiles[0].getCanvasContext().canvas),
|
||||
"Canvas should be tainted.");
|
||||
done();
|
||||
});
|
||||
@ -390,8 +390,8 @@
|
||||
crossOriginPolicy : "Anonymous"
|
||||
}
|
||||
} );
|
||||
viewer.addOnceHandler('tile-drawn', function(event) {
|
||||
assert.ok(!OpenSeadragon.isCanvasTainted(event.tile.getCanvasContext().canvas),
|
||||
viewer.addOnceHandler('tiled-image-drawn', function(event) {
|
||||
assert.ok(!OpenSeadragon.isCanvasTainted(event.tiles[0].getCanvasContext().canvas),
|
||||
"Canvas should not be tainted.");
|
||||
done();
|
||||
});
|
||||
|
@ -45,12 +45,12 @@
|
||||
var openHandler = function(event) {
|
||||
viewer.removeHandler('open', openHandler);
|
||||
assert.ok(true, 'Open event was sent');
|
||||
viewer.addHandler('tile-drawn', tileDrawnHandler);
|
||||
viewer.addHandler('tiled-image-drawn', tileDrawnHandler);
|
||||
};
|
||||
|
||||
var tileDrawnHandler = function(event) {
|
||||
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
||||
assert.ok(true, 'A tile has been drawn');
|
||||
viewer.removeHandler('tiled-image-drawn', tileDrawnHandler);
|
||||
assert.ok(true, 'A tiled image has been drawn');
|
||||
viewer.addHandler('close', closeHandler);
|
||||
viewer.close();
|
||||
};
|
||||
|
@ -178,12 +178,12 @@
|
||||
}
|
||||
|
||||
|
||||
viewer.addHandler('tile-drawn', function tileDrawnHandler(event) {
|
||||
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
||||
viewer.addHandler('tiled-image-drawn', function tileDrawnHandler(event) {
|
||||
viewer.removeHandler('tiled-image-drawn', tileDrawnHandler);
|
||||
handlerCount++;
|
||||
assert.equal(event.eventSource, viewer, 'sender of tile-drawn event was viewer');
|
||||
assert.equal(event.eventSource, viewer, 'sender of tiled-image-drawn event was viewer');
|
||||
assert.equal(event.tiledImage, image, 'tiledImage of update-level event is correct');
|
||||
assert.ok(event.tile, 'tile-drawn event includes tile');
|
||||
assert.ok(event.tiles, 'tiled-image-drawn event includes tiles');
|
||||
|
||||
assert.equal(handlerCount, expectedHandlers, 'correct number of handlers called');
|
||||
done();
|
||||
@ -198,14 +198,14 @@
|
||||
// ----------
|
||||
QUnit.test('reset', function(assert) {
|
||||
var done = assert.async();
|
||||
viewer.addHandler('tile-drawn', function updateHandler() {
|
||||
viewer.removeHandler('tile-drawn', updateHandler);
|
||||
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tile-drawn');
|
||||
viewer.addHandler('tiled-image-drawn', function updateHandler() {
|
||||
viewer.removeHandler('tiled-image-drawn', updateHandler);
|
||||
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tiled-image-drawn');
|
||||
viewer.world.getItemAt(0).reset();
|
||||
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after reset');
|
||||
|
||||
viewer.addHandler('tile-drawn', function updateHandler2() {
|
||||
viewer.removeHandler('tile-drawn', updateHandler2);
|
||||
viewer.addHandler('tiled-image-drawn', function updateHandler2() {
|
||||
viewer.removeHandler('tiled-image-drawn', updateHandler2);
|
||||
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'more tiles load');
|
||||
viewer.world.getItemAt(0).destroy();
|
||||
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after destroy');
|
||||
|
@ -176,9 +176,9 @@
|
||||
// ----------
|
||||
QUnit.test('resetItems', function(assert) {
|
||||
var done = assert.async();
|
||||
viewer.addHandler('tile-drawn', function updateHandler() {
|
||||
viewer.removeHandler('tile-drawn', updateHandler);
|
||||
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tile-drawn');
|
||||
viewer.addHandler('tiled-image-drawn', function updateHandler() {
|
||||
viewer.removeHandler('tiled-image-drawn', updateHandler);
|
||||
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tiled-image-drawn');
|
||||
viewer.world.resetItems();
|
||||
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after reset');
|
||||
done();
|
||||
|
Loading…
Reference in New Issue
Block a user