From ea36e30357501f90bc0df9dfeba2988ec6408dcd Mon Sep 17 00:00:00 2001 From: NikolaBorislavovHristov Date: Fri, 16 Nov 2018 16:32:38 +0200 Subject: [PATCH] vertical slider sliding direction fixed --- src/common/Slider/Slider.js | 5 +++-- src/common/Slider/styles.less | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/common/Slider/Slider.js b/src/common/Slider/Slider.js index 8eb258f4e..2b066b48a 100644 --- a/src/common/Slider/Slider.js +++ b/src/common/Slider/Slider.js @@ -42,7 +42,8 @@ class Slider extends Component { const sliderLength = this.props.orientation === 'horizontal' ? sliderWidth : sliderHeight; const mouseStart = this.props.orientation === 'horizontal' ? mouseX : mouseY; const thumbStart = Math.min(Math.max(mouseStart - sliderStart, 0), sliderLength); - const slidingValue = (thumbStart / sliderLength) * (this.props.maxValue - this.props.minValue) + this.props.minValue; + const slidingValueCoef = this.props.orientation === 'horizontal' ? thumbStart / sliderLength : (sliderLength - thumbStart) / sliderLength; + const slidingValue = slidingValueCoef * (this.props.maxValue - this.props.minValue) + this.props.minValue; return Math.floor(slidingValue); } @@ -83,7 +84,7 @@ class Slider extends Component { } render() { - const thumbStartProp = this.props.orientation === 'horizontal' ? 'left' : 'top'; + const thumbStartProp = this.props.orientation === 'horizontal' ? 'left' : 'bottom'; const thumbStart = (this.props.value - this.props.minValue) / (this.props.maxValue - this.props.minValue); return (
diff --git a/src/common/Slider/styles.less b/src/common/Slider/styles.less index ef9638406..476a9f715 100644 --- a/src/common/Slider/styles.less +++ b/src/common/Slider/styles.less @@ -45,7 +45,7 @@ } .thumb { - transform: translateY(-50%); + transform: translateY(50%); transition-property: top; } }