File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
src/components/segmentedControl Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {asBaseComponent} from '../../commons/new';
14
14
import View from '../view' ;
15
15
import Segment , { SegmentedControlItemProps as SegmentProps } from './segment' ;
16
16
import { Constants } from 'helpers' ;
17
+ import { useOrientation } from 'hooks' ;
17
18
18
19
const BORDER_WIDTH = 1 ;
19
20
const TIMING_CONFIG = {
@@ -105,6 +106,13 @@ const SegmentedControl = (props: SegmentedControlProps) => {
105
106
const segmentedControlHeight = useSharedValue ( 0 ) ;
106
107
const segmentsCounter = useRef ( 0 ) ;
107
108
109
+ useOrientation ( {
110
+ onOrientationChange : ( ) => {
111
+ segmentsCounter . current = 0 ;
112
+ segmentsStyle . value = [ ] ;
113
+ }
114
+ } ) ;
115
+
108
116
// eslint-disable-next-line react-hooks/exhaustive-deps
109
117
const changeIndex = useCallback ( _ . throttle ( ( ) => {
110
118
onChangeIndex ?.( animatedSelectedIndex . value ) ;
@@ -135,7 +143,6 @@ const SegmentedControl = (props: SegmentedControlProps) => {
135
143
segmentsCounter . current ++ ;
136
144
137
145
if ( segmentsCounter . current === segments ?. length ) {
138
- animatedSelectedIndex . value = initialIndex ;
139
146
segmentsStyle . value = [ ...segmentsStyle . value ] ;
140
147
}
141
148
} ,
You can’t perform that action at this time.
0 commit comments