trigger info panel

This commit is contained in:
DIYgod 2018-02-03 21:09:30 +08:00
parent 9b5fccb74c
commit 77a2ba88b4
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
7 changed files with 48 additions and 2 deletions

View File

@ -8,4 +8,5 @@
@import './menu';
@import './notice';
@import './subtitle';
@import './video';
@import './video';
@import './info-panel';

10
src/css/info-panel.scss Normal file
View File

@ -0,0 +1,10 @@
.dplayer-info-panel {
position: absolute;
top: 10px;
left: 10px;
width: 400px;
&-hide {
display: none;
}
}

View File

@ -6,6 +6,7 @@ class ContextMenu {
if (this.player.options.contextmenu[index].click) {
item.addEventListener('click', () => {
this.player.options.contextmenu[index].click(this.player);
this.hide();
});
}
return item;

29
src/js/info-panel.js Normal file
View File

@ -0,0 +1,29 @@
class InfoPanel {
constructor (player) {
this.container = player.template.infoPanel;
this.video = player.video;
}
show () {
this.container.classList.remove('dplayer-info-panel-hide');
}
hide () {
this.container.classList.add('dplayer-info-panel-hide');
}
triggle () {
if (this.container.classList.contains('dplayer-info-panel-hide')) {
this.show();
}
else {
this.hide();
}
}
update () {
}
}
export default InfoPanel;

View File

@ -124,7 +124,7 @@ export default (options) => {
{
text: 'Video info',
click: (player) => {
player.infoPanel.show();
player.infoPanel.triggle();
}
},
{

View File

@ -18,6 +18,7 @@ import Setting from './setting';
import Comment from './comment';
import HotKey from './hotkey';
import ContextMenu from './contextmenu';
import InfoPanel from './info-panel';
let index = 0;
const instances = [];
@ -131,6 +132,8 @@ class DPlayer {
this.initVideo(this.video, this.quality && this.quality.type || this.options.video.type);
this.infoPanel = new InfoPanel(this);
if (!this.danmaku && this.options.autoplay) {
this.play();
}

View File

@ -66,6 +66,7 @@ class Template {
this.barPreview = this.container.querySelector('.dplayer-bar-preview');
this.barWrap = this.container.querySelector('.dplayer-bar-wrap');
this.notice = this.container.querySelector('.dplayer-notice');
this.infoPanel = this.container.querySelector('.dplayer-info-panel');
}
tpl (options, index, tran, icons) {
@ -299,6 +300,7 @@ class Template {
</div>
</div>
</div>
<div class="dplayer-info-panel dplayer-info-panel-hide"></div>
${this.tplContextmenuList(options.contextmenu, tran)}
<div class="dplayer-notice"></div>`;
}