From 19d04ff48b1cb30871c2a5e2183d30e7bd415638 Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Sat, 6 Jul 2024 09:47:30 +0200 Subject: [PATCH] Prevent vertical scrolling when using horizontal scroller --- .../horizontal-scroller.stimulus.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/back/routes/common/horizontal-scroller/horizontal-scroller.stimulus.ts b/src/back/routes/common/horizontal-scroller/horizontal-scroller.stimulus.ts index fce7fdb..59f6270 100644 --- a/src/back/routes/common/horizontal-scroller/horizontal-scroller.stimulus.ts +++ b/src/back/routes/common/horizontal-scroller/horizontal-scroller.stimulus.ts @@ -83,11 +83,19 @@ export default class HorizontalScroller extends Controller { 1 - this.findNextNotFullyVisible([...this.visibility].reverse()) ); - this.elementTargets[index].scrollIntoView({ behavior: "smooth" }); + this.elementTargets[index].scrollIntoView({ + behavior: "smooth", + block: "nearest", + inline: "center", + }); } scrollRight() { const index = this.findNextNotFullyVisible(this.visibility); - this.elementTargets[index].scrollIntoView({ behavior: "smooth" }); + this.elementTargets[index].scrollIntoView({ + behavior: "smooth", + block: "nearest", + inline: "center", + }); } }