@@ -23,12 +23,12 @@ export interface MotionThumbInterface {
2323 onMotionStart : VoidFunction ;
2424 onMotionEnd : VoidFunction ;
2525 direction ?: 'ltr' | 'rtl' ;
26- mode ?: 'horizontal' | 'vertical' ;
26+ vertical ?: boolean ;
2727}
2828
2929const calcThumbStyle = (
3030 targetElement : HTMLElement | null | undefined ,
31- mode : 'horizontal' | 'vertical' ,
31+ vertical ?: boolean ,
3232) : ThumbReact => {
3333 if ( ! targetElement ) return null ;
3434
@@ -47,7 +47,7 @@ const calcThumbStyle = (
4747 height : targetElement . clientHeight ,
4848 } ;
4949
50- if ( mode === ' vertical' ) {
50+ if ( vertical ) {
5151 return {
5252 left : 0 ,
5353 right : 0 ,
@@ -81,7 +81,7 @@ export default function MotionThumb(props: MotionThumbInterface) {
8181 onMotionStart,
8282 onMotionEnd,
8383 direction,
84- mode = 'horizontal' ,
84+ vertical = false ,
8585 } = props ;
8686
8787 const thumbRef = React . useRef < HTMLDivElement > ( null ) ;
@@ -103,8 +103,8 @@ export default function MotionThumb(props: MotionThumbInterface) {
103103 const prev = findValueElement ( prevValue ) ;
104104 const next = findValueElement ( value ) ;
105105
106- const calcPrevStyle = calcThumbStyle ( prev , mode ) ;
107- const calcNextStyle = calcThumbStyle ( next , mode ) ;
106+ const calcPrevStyle = calcThumbStyle ( prev , vertical ) ;
107+ const calcNextStyle = calcThumbStyle ( next , vertical ) ;
108108
109109 setPrevValue ( value ) ;
110110 setPrevStyle ( calcPrevStyle ) ;
@@ -120,26 +120,26 @@ export default function MotionThumb(props: MotionThumbInterface) {
120120
121121 const thumbStart = React . useMemo (
122122 ( ) =>
123- mode === ' vertical'
123+ vertical
124124 ? toPX ( prevStyle ?. top ?? 0 )
125125 : direction === 'rtl'
126126 ? toPX ( - ( prevStyle ?. right as number ) )
127127 : toPX ( prevStyle ?. left as number ) ,
128- [ mode , direction , prevStyle ] ,
128+ [ vertical , direction , prevStyle ] ,
129129 ) ;
130130
131131 const thumbActive = React . useMemo (
132132 ( ) =>
133- mode === ' vertical'
133+ vertical
134134 ? toPX ( nextStyle ?. top ?? 0 )
135135 : direction === 'rtl'
136136 ? toPX ( - ( nextStyle ?. right as number ) )
137137 : toPX ( nextStyle ?. left as number ) ,
138- [ mode , direction , nextStyle ] ,
138+ [ vertical , direction , nextStyle ] ,
139139 ) ;
140140
141141 const onAppearStart = ( ) =>
142- mode === ' vertical'
142+ vertical
143143 ? {
144144 transform : 'translateY(var(--thumb-start-top))' ,
145145 height : 'var(--thumb-start-height)' ,
@@ -150,7 +150,7 @@ export default function MotionThumb(props: MotionThumbInterface) {
150150 } ;
151151
152152 const onAppearActive = ( ) =>
153- mode === ' vertical'
153+ vertical
154154 ? {
155155 transform : 'translateY(var(--thumb-active-top))' ,
156156 height : 'var(--thumb-active-height)' ,
0 commit comments