mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +03:00
make event handler validation private
This commit is contained in:
parent
a55071f67b
commit
024cee42f5
@ -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");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user