diff --git a/src/Eventable.js b/src/Eventable.js index cb3433f4d..a7976b954 100644 --- a/src/Eventable.js +++ b/src/Eventable.js @@ -36,11 +36,11 @@ class Eventable { on (eventType, listener) { // if this type of event was never bound - if (!(eventType in this)) { - this[eventType] = [listener]; + if (this[eventType]) { + this[eventType].push(listener); } else { - this[eventType].push(listener); + this[eventType] = [listener]; } } @@ -50,7 +50,11 @@ class Eventable { const index = eventList? indexOf(eventList, listener) : -1; if (index !== -1) { - this[eventType].splice(index, 1); + eventList.splice(index, 1); + } + let undef; + if (eventList && eventList.length === 0 || undef === listener) { + this[eventType] = undef; } } } diff --git a/src/Interactable.js b/src/Interactable.js index a1a1cb625..0f83e5daa 100644 --- a/src/Interactable.js +++ b/src/Interactable.js @@ -299,7 +299,7 @@ class Interactable { // if it is an action event type if (contains(Interactable.eventTypes, eventType)) { - this.events.on(eventType, listener); + this.events.off(eventType, listener); } // delegated event else if (isType.isString(this.target)) { diff --git a/src/autoStart/index.js b/src/autoStart/index.js index 312a54a9a..69605d77f 100644 --- a/src/autoStart/index.js +++ b/src/autoStart/index.js @@ -186,7 +186,6 @@ Interaction.signals.on('stop', function ({ interaction }) { } }); -<<<<<<< Updated upstream Interactable.prototype.getAction = function (pointer, event, interaction, element) { const action = this.defaultActionChecker(pointer, event, interaction, element); @@ -293,8 +292,6 @@ Interactable.prototype.defaultActionChecker = function (pointer, event, interact } }; -======= ->>>>>>> Stashed changes function withinInteractionLimit (interactable, element, action) { const options = interactable.options; const maxActions = options[action.name].max;