fix segment right scroll

This commit is contained in:
Tanner Reits
2024-10-11 15:51:47 -04:00
parent 1bb7fe87f7
commit f171202ac7

View File

@@ -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',
});
}