mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
update
This commit is contained in:
1 parent
32e93bb875
commit
682dda0ec8
2 files changed
+7
-3
No files matched your search
+6
-2
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user