提取共用方法

This commit is contained in:
Harvey committed 2019-11-14 10:11:03 +08:00
1 parent 48ade99047
commit 7a84c262da
45 files changed
+242 -257

No files matched your search

+4 -2
View File
@@ -1,3 +1,5 @@
import { addClass, removeClass } from './utils';
export default class Notice {
constructor(art) {
this.art = art;
@@ -7,7 +9,7 @@ export default class Notice {
show(msg, autoHide = true, time = 1000) {
const { $player, $noticeInner } = this.art.template;
this.state = true;
$player.classList.add('artplayer-notice-show');
addClass($player, 'artplayer-notice-show');
$noticeInner.innerHTML = msg instanceof Error ? msg.message.trim() : msg;
clearTimeout(this.timer);
if (autoHide) {
@@ -21,7 +23,7 @@ export default class Notice {
hide() {
const { $player } = this.art.template;
this.state = false;
$player.classList.remove('artplayer-notice-show');
removeClass($player, 'artplayer-notice-show');
this.art.emit('notice:hide');
}
}