File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
core/src/components/segment-view Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ export class SegmentView implements ComponentInterface {
3939 @Listen ( 'scroll' )
4040 handleScroll ( ev : Event ) {
4141 const { scrollLeft, scrollWidth, clientWidth } = ev . target as HTMLElement ;
42- const scrollRatio = scrollLeft / ( scrollWidth - clientWidth ) ;
42+ const isRTL = window . getComputedStyle ( this . el ) . direction === 'rtl' ;
43+ const scrollRatio = ( isRTL ? - 1 : 1 ) * scrollLeft / ( scrollWidth - clientWidth ) ;
4344
4445 this . ionSegmentViewScroll . emit ( {
4546 scrollRatio,
@@ -118,6 +119,7 @@ export class SegmentView implements ComponentInterface {
118119 async setContent ( id : string , smoothScroll = true ) {
119120 const contents = this . getSegmentContents ( ) ;
120121 const index = contents . findIndex ( ( content ) => content . id === id ) ;
122+ const isRTL = window . getComputedStyle ( this . el ) . direction === 'rtl' ;
121123
122124 if ( index === - 1 ) return ;
123125
@@ -127,7 +129,7 @@ export class SegmentView implements ComponentInterface {
127129 const contentWidth = this . el . offsetWidth ;
128130 this . el . scrollTo ( {
129131 top : 0 ,
130- left : index * contentWidth ,
132+ left : ( isRTL ? - 1 : 1 ) * index * contentWidth ,
131133 behavior : smoothScroll ? 'smooth' : 'instant' ,
132134 } ) ;
133135 }
You can’t perform that action at this time.
0 commit comments