1
1
<template >
2
2
<div
3
- : ref =" refId "
3
+ ref =" progress "
4
4
class =" vac-player-bar"
5
5
@mousedown =" onMouseDown"
6
6
@mouseover =" $emit('hover-audio-progress', true)"
7
7
@mouseout =" $emit('hover-audio-progress', false)"
8
8
>
9
9
<div class =" vac-player-progress" >
10
- <div class =" vac-line-container" >
11
- <div class =" vac-line-progress" :style =" { width: calculateSize }" />
10
+ <div ref = " line " class =" vac-line-container" >
11
+ <div class =" vac-line-progress" :style =" { width: `${percentage}%` }" />
12
12
<div
13
13
class =" vac-line-dot"
14
14
:class =" { 'vac-line-dot__active': isMouseDown }"
15
- :style =" { left: calculateSize }"
15
+ :style =" { left: `${percentage}%` }"
16
16
/>
17
17
</div >
18
18
</div >
22
22
<script >
23
23
export default {
24
24
props: {
25
- refId: { type: String , default: null },
26
25
percentage: { type: Number , default: 0 }
27
26
},
28
27
@@ -32,16 +31,10 @@ export default {
32
31
}
33
32
},
34
33
35
- computed: {
36
- calculateSize () {
37
- return this .percentage < 1 ? this .percentage * 100 : this .percentage + ' %'
38
- }
39
- },
40
-
41
34
methods: {
42
35
onMouseDown (ev ) {
43
36
this .isMouseDown = true
44
- const seekPos = this .calculateLineHeadPosition (ev, this .$refs [this . refId ])
37
+ const seekPos = this .calculateLineHeadPosition (ev, this .$refs [' progress ' ])
45
38
this .$emit (' change-linehead' , seekPos)
46
39
document .addEventListener (' mousemove' , this .onMouseMove )
47
40
document .addEventListener (' mouseup' , this .onMouseUp )
@@ -50,11 +43,11 @@ export default {
50
43
this .isMouseDown = false
51
44
document .removeEventListener (' mouseup' , this .onMouseUp )
52
45
document .removeEventListener (' mousemove' , this .onMouseMove )
53
- const seekPos = this .calculateLineHeadPosition (ev, this .$refs [this . refId ])
46
+ const seekPos = this .calculateLineHeadPosition (ev, this .$refs [' progress ' ])
54
47
this .$emit (' change-linehead' , seekPos)
55
48
},
56
49
onMouseMove (ev ) {
57
- const seekPos = this .calculateLineHeadPosition (ev, this .$refs [this . refId ])
50
+ const seekPos = this .calculateLineHeadPosition (ev, this .$refs [' progress ' ])
58
51
this .$emit (' change-linehead' , seekPos)
59
52
},
60
53
calculateLineHeadPosition (ev , element ) {
@@ -99,7 +92,7 @@ export default {
99
92
.vac-line-dot {
100
93
position : absolute ;
101
94
top : -6px ;
102
- margin-left : -8 px ;
95
+ margin-left : -15 px ;
103
96
height : 15px ;
104
97
width : 15px ;
105
98
border-radius : 50% ;
0 commit comments