Skip to content

Commit 3f86080

Browse files
authored
fix: moves to the right card depending on route (#3544)
1 parent e8eef82 commit 3f86080

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

assets/components/common/Carousel.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ const scrollToItem = (index: number) => {
4646
};
4747
4848
const { pause, resume } = watchPausable(activeId, (v) => {
49+
if (activeId.value) {
50+
const index = cards.value?.map((c) => c.id).indexOf(activeId.value) ?? -1;
51+
if (index !== -1) {
52+
console.log("watching", activeId.value);
53+
scrollToItem(index);
54+
}
55+
}
56+
});
57+
58+
watchOnce(cards, () => {
4959
if (activeId.value) {
5060
const index = cards.value?.map((c) => c.id).indexOf(activeId.value) ?? -1;
5161
if (index !== -1) {

0 commit comments

Comments
 (0)