mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 22:56:11 +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 ){
|
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
|
* @event tile-drawn
|
||||||
* @memberof OpenSeadragon.Viewer
|
* @memberof OpenSeadragon.Viewer
|
||||||
|
@ -145,7 +145,8 @@ class HTMLDrawer extends $.DrawerBase{
|
|||||||
|
|
||||||
if( this.viewer ){
|
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
|
* @event tile-drawn
|
||||||
* @memberof OpenSeadragon.Viewer
|
* @memberof OpenSeadragon.Viewer
|
||||||
|
@ -342,29 +342,24 @@ $.WebGLDrawer = class WebGLDrawer extends OpenSeadragon.DrawerBase{
|
|||||||
this._drawDebugInfo(tilesToDraw, tiledImage, strokeStyle, fillStyle);
|
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 ){
|
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
|
* @memberof OpenSeadragon.Viewer
|
||||||
* @type {object}
|
* @type {object}
|
||||||
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
||||||
* @property {OpenSeadragon.TiledImage} tiledImage - Which TiledImage is being drawn.
|
* @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.
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||||
*/
|
*/
|
||||||
this.viewer.raiseEvent( 'tile-drawn', {
|
this.viewer.raiseEvent( 'tiled-image-drawn', {
|
||||||
tiledImage: tiledImage,
|
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.
|
// The changeover will look better if we wait for the first tile to be drawn.
|
||||||
var tileDrawnHandler = function(event) {
|
var tileDrawnHandler = function(event) {
|
||||||
if (event.tiledImage === fullImage) {
|
if (event.tiledImage === fullImage) {
|
||||||
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
viewer.removeHandler('tiled-image-drawn', tileDrawnHandler);
|
||||||
viewer.world.removeItem(standin);
|
viewer.world.removeItem(standin);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
viewer.addHandler('tile-drawn', tileDrawnHandler);
|
viewer.addHandler('tiled-image-drawn', tileDrawnHandler);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -322,8 +322,8 @@
|
|||||||
height: 155
|
height: 155
|
||||||
} ]
|
} ]
|
||||||
} );
|
} );
|
||||||
viewer.addOnceHandler('tile-drawn', function(event) {
|
viewer.addOnceHandler('tiled-image-drawn', function(event) {
|
||||||
assert.ok(OpenSeadragon.isCanvasTainted(event.tile.getCanvasContext().canvas),
|
assert.ok(OpenSeadragon.isCanvasTainted(event.tiles[0].getCanvasContext().canvas),
|
||||||
"Canvas should be tainted.");
|
"Canvas should be tainted.");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -342,8 +342,8 @@
|
|||||||
height: 155
|
height: 155
|
||||||
} ]
|
} ]
|
||||||
} );
|
} );
|
||||||
viewer.addOnceHandler('tile-drawn', function(event) {
|
viewer.addOnceHandler('tiled-image-drawn', function(event) {
|
||||||
assert.ok(!OpenSeadragon.isCanvasTainted(event.tile.getCanvasContext().canvas),
|
assert.ok(!OpenSeadragon.isCanvasTainted(event.tiles[0].getCanvasContext().canvas),
|
||||||
"Canvas should not be tainted.");
|
"Canvas should not be tainted.");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -366,8 +366,8 @@
|
|||||||
},
|
},
|
||||||
crossOriginPolicy : false
|
crossOriginPolicy : false
|
||||||
} );
|
} );
|
||||||
viewer.addOnceHandler('tile-drawn', function(event) {
|
viewer.addOnceHandler('tiled-image-drawn', function(event) {
|
||||||
assert.ok(OpenSeadragon.isCanvasTainted(event.tile.getCanvasContext().canvas),
|
assert.ok(OpenSeadragon.isCanvasTainted(event.tiles[0].getCanvasContext().canvas),
|
||||||
"Canvas should be tainted.");
|
"Canvas should be tainted.");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@ -390,8 +390,8 @@
|
|||||||
crossOriginPolicy : "Anonymous"
|
crossOriginPolicy : "Anonymous"
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
viewer.addOnceHandler('tile-drawn', function(event) {
|
viewer.addOnceHandler('tiled-image-drawn', function(event) {
|
||||||
assert.ok(!OpenSeadragon.isCanvasTainted(event.tile.getCanvasContext().canvas),
|
assert.ok(!OpenSeadragon.isCanvasTainted(event.tiles[0].getCanvasContext().canvas),
|
||||||
"Canvas should not be tainted.");
|
"Canvas should not be tainted.");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -45,12 +45,12 @@
|
|||||||
var openHandler = function(event) {
|
var openHandler = function(event) {
|
||||||
viewer.removeHandler('open', openHandler);
|
viewer.removeHandler('open', openHandler);
|
||||||
assert.ok(true, 'Open event was sent');
|
assert.ok(true, 'Open event was sent');
|
||||||
viewer.addHandler('tile-drawn', tileDrawnHandler);
|
viewer.addHandler('tiled-image-drawn', tileDrawnHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
var tileDrawnHandler = function(event) {
|
var tileDrawnHandler = function(event) {
|
||||||
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
viewer.removeHandler('tiled-image-drawn', tileDrawnHandler);
|
||||||
assert.ok(true, 'A tile has been drawn');
|
assert.ok(true, 'A tiled image has been drawn');
|
||||||
viewer.addHandler('close', closeHandler);
|
viewer.addHandler('close', closeHandler);
|
||||||
viewer.close();
|
viewer.close();
|
||||||
};
|
};
|
||||||
|
@ -178,12 +178,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
viewer.addHandler('tile-drawn', function tileDrawnHandler(event) {
|
viewer.addHandler('tiled-image-drawn', function tileDrawnHandler(event) {
|
||||||
viewer.removeHandler('tile-drawn', tileDrawnHandler);
|
viewer.removeHandler('tiled-image-drawn', tileDrawnHandler);
|
||||||
handlerCount++;
|
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.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');
|
assert.equal(handlerCount, expectedHandlers, 'correct number of handlers called');
|
||||||
done();
|
done();
|
||||||
@ -198,14 +198,14 @@
|
|||||||
// ----------
|
// ----------
|
||||||
QUnit.test('reset', function(assert) {
|
QUnit.test('reset', function(assert) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
viewer.addHandler('tile-drawn', function updateHandler() {
|
viewer.addHandler('tiled-image-drawn', function updateHandler() {
|
||||||
viewer.removeHandler('tile-drawn', updateHandler);
|
viewer.removeHandler('tiled-image-drawn', updateHandler);
|
||||||
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tile-drawn');
|
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tiled-image-drawn');
|
||||||
viewer.world.getItemAt(0).reset();
|
viewer.world.getItemAt(0).reset();
|
||||||
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after reset');
|
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after reset');
|
||||||
|
|
||||||
viewer.addHandler('tile-drawn', function updateHandler2() {
|
viewer.addHandler('tiled-image-drawn', function updateHandler2() {
|
||||||
viewer.removeHandler('tile-drawn', updateHandler2);
|
viewer.removeHandler('tiled-image-drawn', updateHandler2);
|
||||||
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'more tiles load');
|
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'more tiles load');
|
||||||
viewer.world.getItemAt(0).destroy();
|
viewer.world.getItemAt(0).destroy();
|
||||||
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after destroy');
|
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after destroy');
|
||||||
|
@ -176,9 +176,9 @@
|
|||||||
// ----------
|
// ----------
|
||||||
QUnit.test('resetItems', function(assert) {
|
QUnit.test('resetItems', function(assert) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
viewer.addHandler('tile-drawn', function updateHandler() {
|
viewer.addHandler('tiled-image-drawn', function updateHandler() {
|
||||||
viewer.removeHandler('tile-drawn', updateHandler);
|
viewer.removeHandler('tiled-image-drawn', updateHandler);
|
||||||
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tile-drawn');
|
assert.ok(viewer.tileCache.numTilesLoaded() > 0, 'we have tiles after tiled-image-drawn');
|
||||||
viewer.world.resetItems();
|
viewer.world.resetItems();
|
||||||
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after reset');
|
assert.equal(viewer.tileCache.numTilesLoaded(), 0, 'no tiles after reset');
|
||||||
done();
|
done();
|
||||||
|
Loading…
Reference in New Issue
Block a user