From e6547432e55d14817b74fded9de1c7d1c9ac8530 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Mon, 30 Sep 2024 09:57:22 -0400 Subject: [PATCH] style: naming --- core/src/components/segment/segment.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/src/components/segment/segment.tsx b/core/src/components/segment/segment.tsx index a74b8e30a8..0419911789 100644 --- a/core/src/components/segment/segment.tsx +++ b/core/src/components/segment/segment.tsx @@ -373,13 +373,15 @@ export class Segment implements ComponentInterface { const indicatorEl = this.getIndicator(current); this.scrolledIndicator = indicatorEl; - const { scrollDistancePercentage, scrollDistance: evScrollDistance } = ev.detail; + const { scrollDistancePercentage, scrollDistance } = ev.detail; if (indicatorEl && !isNaN(scrollDistancePercentage)) { indicatorEl.style.transition = 'transform 0.3s ease-out'; - const scrollDistance = scrollDistancePercentage * current.getBoundingClientRect().width; - const transformValue = evScrollDistance < 0 ? -scrollDistance : scrollDistance; + // Calculate the amount the indicator should move based on the scroll percentage + // and the width of the current button + const scrollAmount = scrollDistancePercentage * current.getBoundingClientRect().width; + const transformValue = scrollDistance < 0 ? -scrollAmount : scrollAmount; // Calculate total width of buttons to the left of the current button const totalButtonWidthBefore = buttons @@ -405,13 +407,13 @@ export class Segment implements ComponentInterface { // Scroll the buttons if the indicator is out of view const indicatorX = indicatorEl.getBoundingClientRect().x; const buttonWidth = current.getBoundingClientRect().width; - if (evScrollDistance < 0 && indicatorX < 0) { + if (scrollDistance < 0 && indicatorX < 0) { this.el.scrollBy({ top: 0, left: indicatorX, behavior: 'instant', }); - } else if (evScrollDistance > 0 && indicatorX + buttonWidth > this.el.offsetWidth) { + } else if (scrollDistance > 0 && indicatorX + buttonWidth > this.el.offsetWidth) { this.el.scrollBy({ top: 0, left: indicatorX + buttonWidth - this.el.offsetWidth,