11<template >
22 <div
3- : ref =" refId "
3+ ref =" progress "
44 class =" vac-player-bar"
55 @mousedown =" onMouseDown"
66 @mouseover =" $emit('hover-audio-progress', true)"
77 @mouseout =" $emit('hover-audio-progress', false)"
88 >
99 <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}%` }" />
1212 <div
1313 class =" vac-line-dot"
1414 :class =" { 'vac-line-dot__active': isMouseDown }"
15- :style =" { left: calculateSize }"
15+ :style =" { left: `${percentage}%` }"
1616 />
1717 </div >
1818 </div >
2222<script >
2323export default {
2424 props: {
25- refId: { type: String , default: null },
2625 percentage: { type: Number , default: 0 }
2726 },
2827
@@ -32,16 +31,10 @@ export default {
3231 }
3332 },
3433
35- computed: {
36- calculateSize () {
37- return this .percentage < 1 ? this .percentage * 100 : this .percentage + ' %'
38- }
39- },
40-
4134 methods: {
4235 onMouseDown (ev ) {
4336 this .isMouseDown = true
44- const seekPos = this .calculateLineHeadPosition (ev, this .$refs [this . refId ])
37+ const seekPos = this .calculateLineHeadPosition (ev, this .$refs [' progress ' ])
4538 this .$emit (' change-linehead' , seekPos)
4639 document .addEventListener (' mousemove' , this .onMouseMove )
4740 document .addEventListener (' mouseup' , this .onMouseUp )
@@ -50,11 +43,11 @@ export default {
5043 this .isMouseDown = false
5144 document .removeEventListener (' mouseup' , this .onMouseUp )
5245 document .removeEventListener (' mousemove' , this .onMouseMove )
53- const seekPos = this .calculateLineHeadPosition (ev, this .$refs [this . refId ])
46+ const seekPos = this .calculateLineHeadPosition (ev, this .$refs [' progress ' ])
5447 this .$emit (' change-linehead' , seekPos)
5548 },
5649 onMouseMove (ev ) {
57- const seekPos = this .calculateLineHeadPosition (ev, this .$refs [this . refId ])
50+ const seekPos = this .calculateLineHeadPosition (ev, this .$refs [' progress ' ])
5851 this .$emit (' change-linehead' , seekPos)
5952 },
6053 calculateLineHeadPosition (ev , element ) {
@@ -99,7 +92,7 @@ export default {
9992 .vac-line-dot {
10093 position : absolute ;
10194 top : -6px ;
102- margin-left : -8 px ;
95+ margin-left : -15 px ;
10396 height : 15px ;
10497 width : 15px ;
10598 border-radius : 50% ;
0 commit comments