File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
core/src/components/segment Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,22 @@ export class Segment implements ComponentInterface {
8888 this . valueAfterGesture = value ;
8989 }
9090 }
91+
92+ if ( this . scrollable ) {
93+ const buttons = this . getButtons ( ) ;
94+ const activeButton = buttons . find ( ( button ) => button . value === value ) ;
95+ if ( activeButton !== undefined ) {
96+ /**
97+ * Scrollable segment buttons should be
98+ * centered within the view including
99+ * buttons that are partially offscreen.
100+ */
101+ activeButton . scrollIntoView ( {
102+ behavior : 'smooth' ,
103+ inline : 'center' ,
104+ } ) ;
105+ }
106+ }
91107 }
92108
93109 /**
Original file line number Diff line number Diff line change 2929 </ ion-segment >
3030 </ ion-toolbar >
3131
32+ < ion-toolbar >
33+ < ion-segment value ="2 " scrollable ="true ">
34+ < ion-segment-button value ="1 "> Button 1</ ion-segment-button >
35+ < ion-segment-button value ="2 "> Button 3</ ion-segment-button >
36+ < ion-segment-button value ="3 "> Button 3</ ion-segment-button >
37+ < ion-segment-button value ="4 "> Button 4</ ion-segment-button >
38+ < ion-segment-button value ="5 "> Button 5</ ion-segment-button >
39+ < ion-segment-button value ="6 "> Button 6</ ion-segment-button >
40+ </ ion-segment >
41+ </ ion-toolbar >
42+
3243 < ion-toolbar >
3344 < ion-segment name ="dynamicPropDisable " disabled color ="danger ">
3445 < ion-segment-button value ="Bookmarks "> Bookmarks </ ion-segment-button >
You can’t perform that action at this time.
0 commit comments