From 3f860805f54a748f6ac6a169981d635639702271 Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Sun, 12 Jan 2025 13:53:53 -0800 Subject: [PATCH] fix: moves to the right card depending on route (#3544) --- assets/components/common/Carousel.vue | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/assets/components/common/Carousel.vue b/assets/components/common/Carousel.vue index 1d8eb05ba6a1..b7a0ea926abf 100644 --- a/assets/components/common/Carousel.vue +++ b/assets/components/common/Carousel.vue @@ -46,6 +46,16 @@ const scrollToItem = (index: number) => { }; const { pause, resume } = watchPausable(activeId, (v) => { + if (activeId.value) { + const index = cards.value?.map((c) => c.id).indexOf(activeId.value) ?? -1; + if (index !== -1) { + console.log("watching", activeId.value); + scrollToItem(index); + } + } +}); + +watchOnce(cards, () => { if (activeId.value) { const index = cards.value?.map((c) => c.id).indexOf(activeId.value) ?? -1; if (index !== -1) {