Skip to content

Commit f9b593d

Browse files
committed
Mobile optimzation
1 parent 6438232 commit f9b593d

8 files changed

Lines changed: 41 additions & 33 deletions

File tree

demo/cplayer.js

Lines changed: 11 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/cplayer.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/index.html

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,8 @@ <h1>cPlayer DEMO</h1>
9595
add163(cp,27669789);
9696
add163(cp,691504);
9797
add163(cp,20744075);
98-
add163(cp,412951925);/*
99-
add163(cp,38574225);
100-
add163(cp,34072418);
101-
add163(cp,32102072);
102-
add163(cp,766471);*/
103-
setTimeout(function(){location.reload()},60*30*1000);
98+
add163(cp,412951925);
99+
//setTimeout(function(){location.reload()},60*30*1000);
104100
addEventListener("keypress",function(e){if(e.keyCode===13)cp.__LIST__.toggle.click()})
105101
</script>
106102
</body>

dist/cplayer.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cplayer.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cPlayer",
3-
"version": "2.5.000",
3+
"version": "2.5.001",
44
"description": "A beautiful and clean WEB Music Player by HTML5.",
55
"main": "dist/cplayer.js",
66
"types": "declaration/cplayer.d.ts",

src/js/cplayer.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class cPlayer extends cEmitter {
9393
"volumeBody": this.CBASE.getByClass("volume-body"),
9494
"volumeLine": this.CBASE.getByClass("volume-line"),
9595
"volumePoint": this.CBASE.getByClass("volume-point"),
96+
"volume": this.CBASE.getByClass("volume"),
9697
"listPower": this.CBASE.getByClass("list-power"),
9798
"list": this.CBASE.getByClass("list"),
9899
"listBody": this.CBASE.getByTagName("list-body")
@@ -125,16 +126,12 @@ class cPlayer extends cEmitter {
125126
},
126127
2: {
127128
get: () => {
128-
return options.target === that.__LIST__.timePoint
129-
|| options.target === that.__LIST__.volumePoint
130-
|| options.target === that.__LIST__.timeBody
129+
return options.target === that.__LIST__.timeBody
131130
|| options.target === that.__LIST__.volumeBody
132-
|| options.target === that.__LIST__.timeLine
133-
|| options.target === that.__LIST__.volumeLine
134131
}
135132
}
136133
});
137-
if (!rightTarget[2]) return;//Warning!!! rightTarget[2] checks if mouse focus on the percentage.
134+
if (!(rightTarget[2] || rightTarget[1] || rightTarget[0])) return;//Warning!!! rightTarget[2] checks if mouse focus on the percentage.
138135
that.dragging.contain = true;
139136
that.dragging.target = <HTMLElement>options.target;
140137
let mover = function (options: MouseEvent) {
@@ -210,6 +207,10 @@ class cPlayer extends cEmitter {
210207
this.hideList();
211208
}
212209
}).on("clickVolumePower", () => {
210+
if (window.innerWidth < 600) {
211+
(<HTMLElement>this.__LIST__.volume.parentElement).classList.toggle("hover");
212+
return;
213+
}
213214
if (this.isMuted()) {
214215
this.music.muted = false;
215216
} else {

src/scss/cplayer.scss

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,23 @@ c-player{
219219
@media screen and (max-width: 600px) {
220220
&{
221221
flex:1;
222+
.volume{
223+
width:auto !important;
224+
.volume-body{visibility: hidden!important}
225+
}
226+
}
227+
&.hover{
228+
.list-button,
229+
.lyric-button{
230+
display:none;
231+
}
232+
.volume-body{
233+
width:100% !important;
234+
visibility: visible !important;
235+
}
236+
.volume{
237+
width:100% !important;
238+
}
222239
}
223240
}
224241
display:flex;
@@ -240,11 +257,6 @@ c-player{
240257
transition: width 0.2s;
241258
}
242259
&:hover,&:active{
243-
@media screen and (max-width: 800px) {
244-
&{
245-
width:100% !important;
246-
}
247-
}
248260
width:12em;
249261
.volume-body{
250262
visibility: visible;
@@ -323,8 +335,6 @@ c-player{
323335
.music-name{
324336
flex:1;
325337
}
326-
.music-artist{
327-
}
328338
}
329339
}
330340
}

0 commit comments

Comments
 (0)