diff --git a/src/canvasdrawer.js b/src/canvasdrawer.js index 67ff6ec8..a637fb39 100644 --- a/src/canvasdrawer.js +++ b/src/canvasdrawer.js @@ -65,6 +65,11 @@ class CanvasDrawer extends $.DrawerBase{ // Canvas default is "true", so this will only be changed if user specifies "false" in the options or via setImageSmoothinEnabled. this._imageSmoothingEnabled = true; + + // Since the tile-drawn and tile-drawing events are fired by this drawer, make sure handlers can be added for them + this.viewer.allowEventHandler("tile-drawn"); + this.viewer.allowEventHandler("tile-drawing"); + } /** diff --git a/src/eventsource.js b/src/eventsource.js index 04b8581b..aa5d917d 100644 --- a/src/eventsource.js +++ b/src/eventsource.js @@ -51,7 +51,7 @@ */ $.EventSource = function() { this.events = {}; - this.rejectedEventList = {}; + this._rejectedEventList = {}; }; /** @lends OpenSeadragon.EventSource.prototype */ @@ -95,8 +95,8 @@ $.EventSource.prototype = { */ addHandler: function ( eventName, handler, userData, priority ) { - if(Object.prototype.hasOwnProperty.call(this.rejectedEventList, eventName)){ - $.console.error(`Error adding handler for ${eventName}. ${this.rejectedEventList[eventName]}`); + if(Object.prototype.hasOwnProperty.call(this._rejectedEventList, eventName)){ + $.console.error(`Error adding handler for ${eventName}. ${this._rejectedEventList[eventName]}`); return false; } @@ -217,9 +217,20 @@ $.EventSource.prototype = { * to be printed to the console * @param {String} eventName - Name of the event * @param {String} [errorMessage] - Optional string to print to the console + * @private */ rejectEventHandler(eventName, errorMessage = ''){ - this.rejectedEventList[eventName] = errorMessage; + this._rejectedEventList[eventName] = errorMessage; + }, + + /** + * Explicitly allow an event handler to be added for this event type, undoing + * the effects of rejectEventHandler + * @param {String} eventName - Name of the event + * @private + */ + allowEventHandler(eventName){ + delete this._rejectedEventList[eventName]; } }; diff --git a/src/htmldrawer.js b/src/htmldrawer.js index ac77f681..a9030702 100644 --- a/src/htmldrawer.js +++ b/src/htmldrawer.js @@ -51,6 +51,8 @@ class HTMLDrawer extends $.DrawerBase{ // Reject listening for the tile-drawing event, which this drawer does not fire this.viewer.rejectEventHandler("tile-drawing", "The HTMLDrawer does not raise the tile-drawing event"); + // Since the tile-drawn event is fired by this drawer, make sure handlers can be added for it + this.viewer.allowEventHandler("tile-drawn"); } /**