This commit is contained in:
Harvey Zack committed 2018-10-15 19:36:16 +08:00
1 parent 32e93bb875
commit 682dda0ec8
2 files changed
+7 -3

No files matched your search

+6 -2
View File
@@ -1,14 +1,14 @@
export default class Events {
constructor(art) {
this.art = art;
this.destroys = [];
this.destroyEvents = [];
this.proxy = this.proxy.bind(this);
this.init();
}
proxy(target, name, callback) {
target.addEventListener(name, callback);
this.destroys.push(() => {
this.destroyEvents.push(() => {
target.removeEventListener(name, callback);
});
}
@@ -16,4 +16,8 @@ export default class Events {
init() {
console.log('Events init');
}
destroy() {
this.destroyEvents.forEach(event => event());
}
}
+1 -1
View File
@@ -90,7 +90,7 @@ class Artplayer extends Emitter {
}
destroy() {
this.events.destroys.forEach(destroy => destroy());
this.events.destroy();
this.refs.$container.innerHTML = '';
instances.splice(instances.indexOf(this), 1);
}