@@ -23,12 +23,12 @@ export interface MotionThumbInterface {
23
23
onMotionStart : VoidFunction ;
24
24
onMotionEnd : VoidFunction ;
25
25
direction ?: 'ltr' | 'rtl' ;
26
- mode ?: 'horizontal' | 'vertical' ;
26
+ vertical ?: boolean ;
27
27
}
28
28
29
29
const calcThumbStyle = (
30
30
targetElement : HTMLElement | null | undefined ,
31
- mode : 'horizontal' | 'vertical' ,
31
+ vertical ?: boolean ,
32
32
) : ThumbReact => {
33
33
if ( ! targetElement ) return null ;
34
34
@@ -47,7 +47,7 @@ const calcThumbStyle = (
47
47
height : targetElement . clientHeight ,
48
48
} ;
49
49
50
- if ( mode === ' vertical' ) {
50
+ if ( vertical ) {
51
51
return {
52
52
left : 0 ,
53
53
right : 0 ,
@@ -81,7 +81,7 @@ export default function MotionThumb(props: MotionThumbInterface) {
81
81
onMotionStart,
82
82
onMotionEnd,
83
83
direction,
84
- mode = 'horizontal' ,
84
+ vertical = false ,
85
85
} = props ;
86
86
87
87
const thumbRef = React . useRef < HTMLDivElement > ( null ) ;
@@ -103,8 +103,8 @@ export default function MotionThumb(props: MotionThumbInterface) {
103
103
const prev = findValueElement ( prevValue ) ;
104
104
const next = findValueElement ( value ) ;
105
105
106
- const calcPrevStyle = calcThumbStyle ( prev , mode ) ;
107
- const calcNextStyle = calcThumbStyle ( next , mode ) ;
106
+ const calcPrevStyle = calcThumbStyle ( prev , vertical ) ;
107
+ const calcNextStyle = calcThumbStyle ( next , vertical ) ;
108
108
109
109
setPrevValue ( value ) ;
110
110
setPrevStyle ( calcPrevStyle ) ;
@@ -120,26 +120,26 @@ export default function MotionThumb(props: MotionThumbInterface) {
120
120
121
121
const thumbStart = React . useMemo (
122
122
( ) =>
123
- mode === ' vertical'
123
+ vertical
124
124
? toPX ( prevStyle ?. top ?? 0 )
125
125
: direction === 'rtl'
126
126
? toPX ( - ( prevStyle ?. right as number ) )
127
127
: toPX ( prevStyle ?. left as number ) ,
128
- [ mode , direction , prevStyle ] ,
128
+ [ vertical , direction , prevStyle ] ,
129
129
) ;
130
130
131
131
const thumbActive = React . useMemo (
132
132
( ) =>
133
- mode === ' vertical'
133
+ vertical
134
134
? toPX ( nextStyle ?. top ?? 0 )
135
135
: direction === 'rtl'
136
136
? toPX ( - ( nextStyle ?. right as number ) )
137
137
: toPX ( nextStyle ?. left as number ) ,
138
- [ mode , direction , nextStyle ] ,
138
+ [ vertical , direction , nextStyle ] ,
139
139
) ;
140
140
141
141
const onAppearStart = ( ) =>
142
- mode === ' vertical'
142
+ vertical
143
143
? {
144
144
transform : 'translateY(var(--thumb-start-top))' ,
145
145
height : 'var(--thumb-start-height)' ,
@@ -150,7 +150,7 @@ export default function MotionThumb(props: MotionThumbInterface) {
150
150
} ;
151
151
152
152
const onAppearActive = ( ) =>
153
- mode === ' vertical'
153
+ vertical
154
154
? {
155
155
transform : 'translateY(var(--thumb-active-top))' ,
156
156
height : 'var(--thumb-active-height)' ,
0 commit comments