Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:side="300"
:circleWidth="20"
:knobRadius="20"
:stepSize="10"
:stepSize="1"
>
</circle-slider>
<div class="value"> {{ sliderValue }} </div>
Expand Down
10 changes: 10 additions & 0 deletions src/components/CircleSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export default {
this.containerElement = this.$refs._svg
this.sliderTolerance = this.radius / 2
this.setNewPosition({x: 0, y: 0})

this.containerElement.addEventListener('wheel', this.handleWheelScroll)
},
beforeDestroy () {
this.containerElement.removeEventListener('wheel', this.handleWheelScroll)
},
props: {
startAngleOffset: {
Expand Down Expand Up @@ -327,6 +332,11 @@ export default {
const dimensions = this.containerElement.getBoundingClientRect()
this.relativeX = e.clientX - dimensions.left
this.relativeY = e.clientY - dimensions.top
},
handleWheelScroll (e) {
e.preventDefault()
const valueFromScroll = e.wheelDelta > 0 ? this.value + this.stepSize : this.value - this.stepSize
this.updateFromPropValue(valueFromScroll)
}
},
watch: {
Expand Down