Skip to content

Commit

Permalink
Fix once events unbinding
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Feb 22, 2019
1 parent 2444e2f commit 2f8d520
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ class SwiperClass {
function onceHandler(...args) {
handler.apply(self, args);
self.off(events, onceHandler);
if (onceHandler.f7proxy) {
delete onceHandler.f7proxy;
}
}
onceHandler.f7proxy = handler;
return self.on(events, onceHandler, priority);
}

Expand All @@ -44,7 +48,7 @@ class SwiperClass {
self.eventsListeners[event] = [];
} else if (self.eventsListeners[event] && self.eventsListeners[event].length) {
self.eventsListeners[event].forEach((eventHandler, index) => {
if (eventHandler === handler) {
if (eventHandler === handler || (eventHandler.f7proxy && eventHandler.f7proxy === handler)) {
self.eventsListeners[event].splice(index, 1);
}
});
Expand Down

0 comments on commit 2f8d520

Please sign in to comment.