From 9725ac0398bdcae8d68def23372007404bed223e Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 10 Jan 2024 12:21:05 -0500 Subject: [PATCH] update tiled-image-drawn event description --- src/canvasdrawer.js | 40 +++++++++++----------------------------- src/webgldrawer.js | 44 ++++++++++++-------------------------------- 2 files changed, 23 insertions(+), 61 deletions(-) diff --git a/src/canvasdrawer.js b/src/canvasdrawer.js index b63c2ed0..c013b0bc 100644 --- a/src/canvasdrawer.js +++ b/src/canvasdrawer.js @@ -101,24 +101,6 @@ class CanvasDrawer extends $.DrawerBase{ this._drawTiles(tiledImage); } } - - // // Fire the frame-drawn event. - // if( this.viewer ){ - // /** - // * Raised when a tiled image is drawn to the canvas. Only valid - // * for webgl and canvas drawers. - // * - // * @event tiled-image-drawn - // * @memberof OpenSeadragon.Viewer - // * @type {object} - // * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event. - // * @property {HTMLElement} canvas - The canvas which has been drawn onto - // * @property {?Object} userData - Arbitrary subscriber-defined object. - // */ - // this.viewer.raiseEvent( 'frame-drawn', { - // canvas: this.canvas - // }); - // } } /** @@ -499,17 +481,17 @@ class CanvasDrawer extends $.DrawerBase{ // Fire tiled-image-drawn event. if( this.viewer ){ /** - * Raised when a tiled image is drawn to the canvas. Only valid - * for webgl and canvas drawers. - * - * @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 {Array} tiles - An array of Tile objects that were drawn. - * @property {?Object} userData - Arbitrary subscriber-defined object. - */ + * Raised when a tiled image is drawn to the canvas. Used internally for testing. + * The update-viewport event is preferred if you want to know when a frame has been 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 {Array} tiles - An array of Tile objects that were drawn. + * @property {?Object} userData - Arbitrary subscriber-defined object. + */ this.viewer.raiseEvent( 'tiled-image-drawn', { tiledImage: tiledImage, tiles: lastDrawn, diff --git a/src/webgldrawer.js b/src/webgldrawer.js index 90e802d4..3a50d5f8 100644 --- a/src/webgldrawer.js +++ b/src/webgldrawer.js @@ -352,22 +352,20 @@ gl.clear(gl.COLOR_BUFFER_BIT); // clear the back buffer } - // Fire tiled-image-drawn event. - // TODO: for discussion: do we need to ensure the image has been drawn to the output canvas already? - // Is it possible the image data may not be on the output canvas? Does it matter? + // Fire tiled-image-drawn event. This is used for the tests if( this.viewer ){ /** - * Raised when a tiled image is drawn to the canvas. Only valid - * for webgl and canvas drawers. - * - * @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 {Array} tiles - An array of Tile objects that were drawn. - * @property {?Object} userData - Arbitrary subscriber-defined object. - */ + * Raised when a tiled image is drawn to the canvas. Used internally for testing. + * The update-viewport event is preferred if you want to know when a frame has been 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 {Array} tiles - An array of Tile objects that were drawn. + * @property {?Object} userData - Arbitrary subscriber-defined object. + */ this.viewer.raiseEvent( 'tiled-image-drawn', { tiledImage: tiledImage, tiles: tilesToDraw.map(info => info.tile), @@ -380,24 +378,6 @@ this._outputContext.drawImage(this._renderingCanvas, 0, 0); } - // // Fire the frame-drawn event. - // if( this.viewer ){ - // /** - // * Raised when a tiled image is drawn to the canvas. Only valid - // * for webgl and canvas drawers. - // * - // * @event tiled-image-drawn - // * @memberof OpenSeadragon.Viewer - // * @type {object} - // * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event. - // * @property {HTMLElement} canvas - The canvas which has been drawn onto - // * @property {?Object} userData - Arbitrary subscriber-defined object. - // */ - // this.viewer.raiseEvent( 'frame-drawn', { - // canvas: this.canvas - // }); - // } - } // Public API required by all Drawer implementations