Ionic 4 ion-segment scrollable actived position

When we have more number of segments in ion-segments with scrollable true, when we change selected segment through programmatically the selected segment is not visible in display (Manually we need to scroll segments)… How to set position of selected segment or how to make it center of selected segment.

example: Added swipeleft and swiperight gesture to the segments, based on the swipe direction i am changing selected segment programmatically. Segments is changing but its not scrolled to selected

Please help me out

1 Like

Hey, possible solution would be to set id for ion-segment and every ion-segment-button and on change to call function where you would scroll ion-segment to specific position.
E.g.
document.getElementById(‘segment’).scroll(document.getElementById(‘segmentButton’).offsetLeft - (window.innerWidth / 2) + (document.getElementById(‘segmentButton’).clientWidth / 2), 0);

This should scroll it to the center of the screen.