const -> let

master
yutent 2023-11-22 18:33:21 +08:00
parent 268bd8f87d
commit 0cde6f7c02
1 changed files with 15 additions and 15 deletions

View File

@ -204,16 +204,16 @@ class Slider extends Component {
this.$tips.classList.toggle('show') this.$tips.classList.toggle('show')
preValue = +preValue || min preValue = +preValue || min
const start = vertical ? e.clientY : e.clientX let start = vertical ? e.clientY : e.clientX
const onMousemove = bind(document, 'mousemove', e => { let onMousemove = bind(document, 'mousemove', e => {
e.preventDefault() e.preventDefault()
const distance = (vertical ? e.clientY : e.clientX) - start let distance = (vertical ? e.clientY : e.clientX) - start
const scale = let scale =
(distance / (distance /
(vertical ? this.$runway.clientHeight : this.$runway.clientWidth)) * (vertical ? this.$runway.clientHeight : this.$runway.clientWidth)) *
(vertical ? -1 : 1) (vertical ? -1 : 1)
const diff = let diff =
accuracy === 0 ? Math.round(scale * (max - min)) : scale * (max - min) accuracy === 0 ? Math.round(scale * (max - min)) : scale * (max - min)
let newProgress = progress + Math.floor(scale * 100) let newProgress = progress + Math.floor(scale * 100)
let newValue = let newValue =
@ -239,7 +239,7 @@ class Slider extends Component {
this.$emit('input') this.$emit('input')
}) })
const onMouseup = bind(document, 'mouseup', () => { let onMouseup = bind(document, 'mouseup', () => {
unbind(document, 'mousemove', onMousemove) unbind(document, 'mousemove', onMousemove)
unbind(document, 'mouseup', onMouseup) unbind(document, 'mouseup', onMouseup)
this.$tips.classList.toggle('show') this.$tips.classList.toggle('show')
@ -254,10 +254,10 @@ class Slider extends Component {
if (disabled || readOnly) { if (disabled || readOnly) {
return return
} }
const { clientWidth, clientHeight } = e.target let { clientWidth, clientHeight } = e.target
const { offsetX, offsetY } = e let { offsetX, offsetY } = e
const range = max - min let range = max - min
const scale = let scale =
(vertical ? offsetY : offsetX) / (vertical ? clientHeight : clientWidth) (vertical ? offsetY : offsetX) / (vertical ? clientHeight : clientWidth)
step *= Math.pow(10, accuracy) step *= Math.pow(10, accuracy)
@ -266,7 +266,7 @@ class Slider extends Component {
+(scale * range + min).toFixed(accuracy) * Math.pow(10, accuracy) +(scale * range + min).toFixed(accuracy) * Math.pow(10, accuracy)
let mod = +(newValue % step).toFixed(accuracy) let mod = +(newValue % step).toFixed(accuracy)
if (mod) { if (mod) {
const half = step / 2 let half = step / 2
if (mod > half) { if (mod > half) {
newValue += step - mod newValue += step - mod
} else { } else {
@ -276,7 +276,7 @@ class Slider extends Component {
newValue *= Math.pow(10, -accuracy) newValue *= Math.pow(10, -accuracy)
this.value = (vertical ? range - newValue : newValue).toFixed(accuracy) this.value = (vertical ? range - newValue : newValue).toFixed(accuracy)
const progress = Math.floor(((newValue - min) / range) * 100) let progress = Math.floor(((newValue - min) / range) * 100)
this.setProgress(progress) this.setProgress(progress)
this.$emit('change') this.$emit('change')
this.$emit('input') this.$emit('input')
@ -292,11 +292,11 @@ class Slider extends Component {
}, 1000) }, 1000)
} }
initValue(val) { initValue(val) {
const { max, min, vertical, disabled, readOnly } = this let { max, min, vertical, disabled, readOnly } = this
if (disabled || readOnly) { if (disabled || readOnly) {
return return
} }
const range = max - min let range = max - min
val = Math.max(val, min) val = Math.max(val, min)
val = Math.min(val, max) val = Math.min(val, max)
this.value = val this.value = val
@ -305,7 +305,7 @@ class Slider extends Component {
this.setProgress(progress) this.setProgress(progress)
} }
setProgress(val) { setProgress(val) {
const { vertical } = this let { vertical } = this
val = Math.floor(val) val = Math.floor(val)
val = Math.min(val, 100) val = Math.min(val, 100)
val = Math.max(val, 0) val = Math.max(val, 0)