mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 08:42:21 -08:00
update control
This commit is contained in:
1 parent
ea4ec61fd7
commit
c1780c3137
4 files changed
+57
-29
No files matched your search
@@ -18,33 +18,52 @@ export default class Control extends Component {
|
||||
super(art);
|
||||
|
||||
this.name = 'control';
|
||||
this.timer = Date.now();
|
||||
|
||||
const {
|
||||
proxy,
|
||||
constructor,
|
||||
template: { $player },
|
||||
template: { $video },
|
||||
} = art;
|
||||
|
||||
let activeTime = Date.now();
|
||||
|
||||
proxy($player, ['click', 'mousemove', 'touchstart', 'touchmove'], () => {
|
||||
this.show = true;
|
||||
removeClass($player, 'art-hide-cursor');
|
||||
addClass($player, 'art-hover');
|
||||
activeTime = Date.now();
|
||||
proxy($video, ['click', 'mousemove'], (event) => {
|
||||
if (isMobile) {
|
||||
if (event.type === 'click') {
|
||||
this.show = !this.show;
|
||||
}
|
||||
} else {
|
||||
this.show = true;
|
||||
}
|
||||
});
|
||||
|
||||
art.on('video:timeupdate', () => {
|
||||
if (!art.isInput && art.playing && this.show && Date.now() - activeTime >= constructor.CONTROL_HIDE_TIME) {
|
||||
if (!art.isInput && art.playing && this.show && Date.now() - this.timer >= constructor.CONTROL_HIDE_TIME) {
|
||||
this.show = false;
|
||||
addClass($player, 'art-hide-cursor');
|
||||
removeClass($player, 'art-hover');
|
||||
}
|
||||
});
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
set show(state) {
|
||||
const { $player } = this.art.template;
|
||||
|
||||
if (state) {
|
||||
removeClass($player, 'art-hide-cursor');
|
||||
addClass($player, 'art-hover');
|
||||
this.timer = Date.now();
|
||||
} else {
|
||||
addClass($player, 'art-hide-cursor');
|
||||
removeClass($player, 'art-hover');
|
||||
}
|
||||
|
||||
super.show = state;
|
||||
}
|
||||
|
||||
get show() {
|
||||
return super.show;
|
||||
}
|
||||
|
||||
init() {
|
||||
const { option } = this.art;
|
||||
|
||||
|
||||
Reference in new issue
Block a user