Skip to content

Commit

Permalink
feat(comp:slider): unify trigger conditions for change events (#721)
Browse files Browse the repository at this point in the history
fix #696
  • Loading branch information
imguolao committed Jan 13, 2022
1 parent 8b5212b commit a3209fa
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions packages/components/slider/src/useSlider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export function useSlider(props: SliderProps): SliderBindings {
val = [modelValue as number]
}

const newVal = val
valuesRef.value = val
.map(num => {
if (!isNumeric(num)) {
return props.min
Expand All @@ -317,15 +317,6 @@ export function useSlider(props: SliderProps): SliderBindings {
return calcValueByStep(num)
})
.sort((a, b) => a - b) // order

// When the legal value is not equal to the modelValue, update modelValue
if (val.every((v, i) => v !== newVal[i])) {
const modelValue = props.range ? newVal : newVal[0]
callEmit(props.onChange, modelValue)
accessor.setValue(modelValue)
}

valuesRef.value = newVal
}

return {
Expand Down

0 comments on commit a3209fa

Please sign in to comment.