Skip to content

Commit 493c95f

Browse files
committed
optimize thumbnails and bar-time in mobile
1 parent d753f82 commit 493c95f

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dplayer",
3-
"version": "1.21.0",
3+
"version": "1.21.1",
44
"description": "Wow, such a lovely HTML5 danmaku video player",
55
"main": "dist/DPlayer.min.js",
66
"style": "dist/DPlayer.min.css",

src/css/player.scss

+12-7
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,20 @@
140140
width: 100%;
141141
height: 100%;
142142
}
143-
&.dplayer-mobile .dplayer-controller .dplayer-icons {
144-
.dplayer-volume,
145-
.dplayer-camera-icon {
146-
display: none;
143+
&.dplayer-mobile {
144+
.dplayer-controller .dplayer-icons {
145+
.dplayer-volume,
146+
.dplayer-camera-icon {
147+
display: none;
148+
}
149+
.dplayer-full .dplayer-full-in-icon {
150+
position: static;
151+
display: inline-block;
152+
}
147153
}
148154

149-
.dplayer-full .dplayer-full-in-icon {
150-
position: static;
151-
display: inline-block;
155+
.dplayer-bar-time {
156+
display: none;
152157
}
153158
}
154159
}

src/js/controller.js

+21-10
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,37 @@ class Controller {
105105
return;
106106
}
107107
const time = this.player.video.duration * (tx / this.player.template.playedBarWrap.offsetWidth);
108+
if (utils.isMobile) {
109+
this.thumbnails && this.thumbnails.show();
110+
}
108111
this.thumbnails && this.thumbnails.move(tx);
109112
this.player.template.playedBarTime.style.left = `${(tx - 20)}px`;
110113
this.player.template.playedBarTime.innerText = utils.secondToTime(time);
111114
this.player.template.playedBarTime.classList.remove('hidden');
112115
}
113116
});
114117

115-
this.player.template.playedBarWrap.addEventListener('mouseenter', () => {
116-
if (this.player.video.duration) {
117-
this.thumbnails && this.thumbnails.show();
118-
this.player.template.playedBarTime.classList.remove('hidden');
119-
}
120-
});
121-
122-
this.player.template.playedBarWrap.addEventListener('mouseleave', () => {
123-
if (this.player.video.duration) {
118+
this.player.template.playedBarWrap.addEventListener(utils.nameMap.dragEnd, () => {
119+
if (utils.isMobile) {
124120
this.thumbnails && this.thumbnails.hide();
125-
this.player.template.playedBarTime.classList.add('hidden');
126121
}
127122
});
123+
124+
if (!utils.isMobile) {
125+
this.player.template.playedBarWrap.addEventListener('mouseenter', () => {
126+
if (this.player.video.duration) {
127+
this.thumbnails && this.thumbnails.show();
128+
this.player.template.playedBarTime.classList.remove('hidden');
129+
}
130+
});
131+
132+
this.player.template.playedBarWrap.addEventListener('mouseleave', () => {
133+
if (this.player.video.duration) {
134+
this.thumbnails && this.thumbnails.hide();
135+
this.player.template.playedBarTime.classList.add('hidden');
136+
}
137+
});
138+
}
128139
}
129140

130141
initFullButton () {

0 commit comments

Comments
 (0)