From 75fd7ed6c7ca635d39b2c303045d69b422419db6 Mon Sep 17 00:00:00 2001 From: jrojas Date: Fri, 10 May 2019 15:18:54 -0700 Subject: [PATCH] Allow radius to be dynamically configured. --- src/components/CircleSlider.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/CircleSlider.vue b/src/components/CircleSlider.vue index 7119c9d..1ec2996 100644 --- a/src/components/CircleSlider.vue +++ b/src/components/CircleSlider.vue @@ -29,10 +29,9 @@ export default { this.angle = this.circleSliderState.angleValue this.currentStepValue = this.circleSliderState.currentStep - let maxCurveWidth = Math.max(this.cpMainCircleStrokeWidth, this.cpPathStrokeWidth) - this.radius = (this.side / 2) - Math.max(maxCurveWidth, this.cpKnobRadius * 2) / 2 this.updateFromPropValue(this.value) }, + mounted () { this.touchPosition = new TouchPosition(this.$refs._svg, this.radius, this.radius / 2) }, @@ -130,7 +129,6 @@ export default { return { steps: null, stepsCount: null, - radius: 0, angle: 0, currentStepValue: 0, mousePressed: false, @@ -181,6 +179,11 @@ export default { parts.push(this.cpPathX) parts.push(this.cpPathY) return parts.join(' ') + }, + + radius() { + let maxCurveWidth = Math.max(this.cpMainCircleStrokeWidth, this.cpPathStrokeWidth) + return (this.side / 2) - Math.max(maxCurveWidth, this.cpKnobRadius * 2) / 2 } }, methods: {