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