@@ -16,7 +16,7 @@ export const styles = theme => {
1616
1717 const trackTransitions = theme . transitions . create ( [ 'width' , 'height' ] , commonTransitionsOptions ) ;
1818 const thumbCommonTransitions = theme . transitions . create (
19- [ 'width' , 'height' , 'left' , 'right' , 'top ' , 'box-shadow' ] ,
19+ [ 'width' , 'height' , 'left' , 'right' , 'bottom ' , 'box-shadow' ] ,
2020 commonTransitionsOptions ,
2121 ) ;
2222 // no transition on the position
@@ -76,6 +76,7 @@ export const styles = theme => {
7676 transform : 'translate(-50%, 0)' ,
7777 left : '50%' ,
7878 top : 'initial' ,
79+ bottom : 0 ,
7980 width : 2 ,
8081 } ,
8182 } ,
@@ -120,6 +121,9 @@ export const styles = theme => {
120121 '&$jumped' : {
121122 boxShadow : `0px 0px 0px ${ pressedOutlineRadius * 2 } px ${ colors . thumbOutline } ` ,
122123 } ,
124+ '&$vertical' : {
125+ transform : 'translate(-50%, +50%)' ,
126+ } ,
123127 } ,
124128 /* Class applied to the thumb element if custom thumb icon provided. */
125129 thumbIconWrapper : {
@@ -152,10 +156,10 @@ function roundToStep(number, step) {
152156
153157function getOffset ( node ) {
154158 const { pageYOffset, pageXOffset } = global ;
155- const { left, top } = node . getBoundingClientRect ( ) ;
159+ const { left, bottom } = node . getBoundingClientRect ( ) ;
156160
157161 return {
158- top : top + pageYOffset ,
162+ bottom : bottom + pageYOffset ,
159163 left : left + pageXOffset ,
160164 } ;
161165}
@@ -176,10 +180,10 @@ function getMousePosition(event) {
176180
177181function calculatePercent ( node , event , isVertical , isRtl ) {
178182 const { width, height } = node . getBoundingClientRect ( ) ;
179- const { top , left } = getOffset ( node ) ;
183+ const { bottom , left } = getOffset ( node ) ;
180184 const { x, y } = getMousePosition ( event ) ;
181185
182- const value = isVertical ? y - top : x - left ;
186+ const value = isVertical ? bottom - y : x - left ;
183187 const onePercent = ( isVertical ? height : width ) / 100 ;
184188
185189 return isRtl && ! isVertical ? 100 - clamp ( value / onePercent ) : clamp ( value / onePercent ) ;
@@ -413,6 +417,7 @@ class Slider extends React.Component {
413417 [ classes . jumped ] : ! disabled && currentState === 'jumped' ,
414418 [ classes . focused ] : ! disabled && currentState === 'focused' ,
415419 [ classes . activated ] : ! disabled && currentState === 'activated' ,
420+ [ classes . vertical ] : vertical ,
416421 } ;
417422
418423 const className = classNames (
@@ -428,17 +433,12 @@ class Slider extends React.Component {
428433 [ classes . vertical ] : vertical ,
429434 } ) ;
430435
431- const trackBeforeClasses = classNames ( classes . track , classes . trackBefore , commonClasses , {
432- [ classes . vertical ] : vertical ,
433- } ) ;
434-
435- const trackAfterClasses = classNames ( classes . track , classes . trackAfter , commonClasses , {
436- [ classes . vertical ] : vertical ,
437- } ) ;
436+ const trackBeforeClasses = classNames ( classes . track , classes . trackBefore , commonClasses ) ;
437+ const trackAfterClasses = classNames ( classes . track , classes . trackAfter , commonClasses ) ;
438438
439439 const trackProperty = vertical ? 'height' : 'width' ;
440440 const horizontalMinimumPosition = theme . direction === 'ltr' ? 'left' : 'right' ;
441- const thumbProperty = vertical ? 'top ' : horizontalMinimumPosition ;
441+ const thumbProperty = vertical ? 'bottom ' : horizontalMinimumPosition ;
442442 const inlineTrackBeforeStyles = { [ trackProperty ] : this . calculateTrackBeforeStyles ( percent ) } ;
443443 const inlineTrackAfterStyles = { [ trackProperty ] : this . calculateTrackAfterStyles ( percent ) } ;
444444 const inlineThumbStyles = { [ thumbProperty ] : `${ percent } %` } ;
0 commit comments