Prevent vertical scrolling when using horizontal scroller

This commit is contained in:
Kuba Orlik 2024-07-06 09:47:30 +02:00
parent b46ba714c3
commit 19d04ff48b

View File

@ -83,11 +83,19 @@ export default class HorizontalScroller extends Controller {
1 - 1 -
this.findNextNotFullyVisible([...this.visibility].reverse()) this.findNextNotFullyVisible([...this.visibility].reverse())
); );
this.elementTargets[index].scrollIntoView({ behavior: "smooth" }); this.elementTargets[index].scrollIntoView({
behavior: "smooth",
block: "nearest",
inline: "center",
});
} }
scrollRight() { scrollRight() {
const index = this.findNextNotFullyVisible(this.visibility); const index = this.findNextNotFullyVisible(this.visibility);
this.elementTargets[index].scrollIntoView({ behavior: "smooth" }); this.elementTargets[index].scrollIntoView({
behavior: "smooth",
block: "nearest",
inline: "center",
});
} }
} }