File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
core/src/components/segment Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -401,6 +401,23 @@ export class Segment implements ComponentInterface {
401401 // Apply the clamped transform value to the indicator element
402402 const transform = `translate3d(${ clampedTransform } px, 0, 0)` ;
403403 indicatorEl . style . setProperty ( 'transform' , transform ) ;
404+
405+ // Scroll the buttons if the indicator is out of view
406+ const indicatorX = indicatorEl . getBoundingClientRect ( ) . x ;
407+ const buttonWidth = current . getBoundingClientRect ( ) . width ;
408+ if ( evScrollDistance < 0 && indicatorX < 0 ) {
409+ this . el . scrollBy ( {
410+ top : 0 ,
411+ left : indicatorX ,
412+ behavior : 'instant' ,
413+ } ) ;
414+ } else if ( evScrollDistance > 0 && indicatorX + buttonWidth > this . el . offsetWidth ) {
415+ this . el . scrollBy ( {
416+ top : 0 ,
417+ left : indicatorX + buttonWidth - this . el . offsetWidth ,
418+ behavior : 'instant' ,
419+ } ) ;
420+ }
404421 }
405422 }
406423 }
You can’t perform that action at this time.
0 commit comments