diff --git a/core/src/components/segment/segment.tsx b/core/src/components/segment/segment.tsx index e5024bbd1f..d764fffa88 100644 --- a/core/src/components/segment/segment.tsx +++ b/core/src/components/segment/segment.tsx @@ -459,7 +459,8 @@ export class Segment implements ComponentInterface { } // Scroll the segment container if the indicator is out of view - const indicatorX = indicator.getBoundingClientRect().x; + const indicatorRect = indicator.getBoundingClientRect(); + const indicatorX = indicatorRect.x; if (scrollDistance < 0 && indicatorX < 0) { this.el.scrollBy({ top: 0, @@ -469,7 +470,7 @@ export class Segment implements ComponentInterface { } else if (scrollDistance > 0 && indicatorX + currentButtonWidth > this.el.offsetWidth) { this.el.scrollBy({ top: 0, - left: indicatorX + currentButtonWidth - this.el.offsetWidth, + left: indicatorX + indicatorRect.width - this.el.offsetWidth, behavior: 'instant', }); }