Skip to content

Commit e654743

Browse files
committed
style: naming
1 parent c6ec156 commit e654743

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

core/src/components/segment/segment.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,15 @@ export class Segment implements ComponentInterface {
373373
const indicatorEl = this.getIndicator(current);
374374
this.scrolledIndicator = indicatorEl;
375375

376-
const { scrollDistancePercentage, scrollDistance: evScrollDistance } = ev.detail;
376+
const { scrollDistancePercentage, scrollDistance } = ev.detail;
377377

378378
if (indicatorEl && !isNaN(scrollDistancePercentage)) {
379379
indicatorEl.style.transition = 'transform 0.3s ease-out';
380380

381-
const scrollDistance = scrollDistancePercentage * current.getBoundingClientRect().width;
382-
const transformValue = evScrollDistance < 0 ? -scrollDistance : scrollDistance;
381+
// Calculate the amount the indicator should move based on the scroll percentage
382+
// and the width of the current button
383+
const scrollAmount = scrollDistancePercentage * current.getBoundingClientRect().width;
384+
const transformValue = scrollDistance < 0 ? -scrollAmount : scrollAmount;
383385

384386
// Calculate total width of buttons to the left of the current button
385387
const totalButtonWidthBefore = buttons
@@ -405,13 +407,13 @@ export class Segment implements ComponentInterface {
405407
// Scroll the buttons if the indicator is out of view
406408
const indicatorX = indicatorEl.getBoundingClientRect().x;
407409
const buttonWidth = current.getBoundingClientRect().width;
408-
if (evScrollDistance < 0 && indicatorX < 0) {
410+
if (scrollDistance < 0 && indicatorX < 0) {
409411
this.el.scrollBy({
410412
top: 0,
411413
left: indicatorX,
412414
behavior: 'instant',
413415
});
414-
} else if (evScrollDistance > 0 && indicatorX + buttonWidth > this.el.offsetWidth) {
416+
} else if (scrollDistance > 0 && indicatorX + buttonWidth > this.el.offsetWidth) {
415417
this.el.scrollBy({
416418
top: 0,
417419
left: indicatorX + buttonWidth - this.el.offsetWidth,

0 commit comments

Comments
 (0)