Skip to content

Commit 55e08ce

Browse files
committed
fix: 🐛 (xgplayer) ensure poster is hidden when play catched
1 parent 2d6e6cc commit 55e08ce

File tree

1 file changed

+12
-4
lines changed
  • packages/xgplayer/src/plugins/poster

1 file changed

+12
-4
lines changed

packages/xgplayer/src/plugins/poster/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ class Poster extends Plugin {
3535
}
3636

3737
hide () {
38-
Util.addClass(this.root, 'hide')
38+
if (!this.isHide) {
39+
Util.addClass(this.root, 'hide')
40+
this.isHide = true
41+
}
3942
}
4043

4144
/**
4245
* @param {string} [value]
4346
* @returns
4447
*/
4548
show (value) {
49+
this.isHide = false
4650
Util.removeClass(this.root, 'hide')
4751
}
4852

@@ -55,24 +59,28 @@ class Poster extends Plugin {
5559
afterCreate () {
5660
this.on(Events.ENDED, () => {
5761
if (this.isEndedShow) {
58-
Util.removeClass(this.root, 'hide')
62+
this.show()
5963
}
6064
})
6165

66+
this.on(Events.PLAYING, () => {
67+
this.hide()
68+
})
69+
6270
if (this.config.hideCanplay) {
6371
this.once(Events.TIME_UPDATE, () => {
6472
this.onTimeUpdate()
6573
})
6674
this.on(Events.URL_CHANGE, () => {
67-
Util.removeClass(this.root, 'hide')
75+
this.show()
6876
Util.addClass(this.root, 'xg-showplay')
6977
this.once(Events.TIME_UPDATE, () => {
7078
this.onTimeUpdate()
7179
})
7280
})
7381
} else {
7482
this.on(Events.PLAY, () => {
75-
Util.addClass(this.root, 'hide')
83+
this.hide()
7684
})
7785
}
7886
}

0 commit comments

Comments
 (0)