File tree 2 files changed +27
-0
lines changed
core/src/components/segment
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 {
88
88
this . valueAfterGesture = value ;
89
89
}
90
90
}
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
+ }
91
107
}
92
108
93
109
/**
Original file line number Diff line number Diff line change 29
29
</ ion-segment >
30
30
</ ion-toolbar >
31
31
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
+
32
43
< ion-toolbar >
33
44
< ion-segment name ="dynamicPropDisable " disabled color ="danger ">
34
45
< ion-segment-button value ="Bookmarks "> Bookmarks </ ion-segment-button >
You can’t perform that action at this time.
0 commit comments