From f171202ac70d1cffb68694c99dbb139f4e51d684 Mon Sep 17 00:00:00 2001 From: Tanner Reits Date: Fri, 11 Oct 2024 15:51:47 -0400 Subject: [PATCH] fix segment right scroll --- core/src/components/segment/segment.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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', }); }