Skip to content

Commit

Permalink
feat: change tab on swipe
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Bedon committed Nov 12, 2024
1 parent c725082 commit a81108e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/MyKiva/BorrowerCarousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</div>
</template>
<div v-if="hasActiveLoans && !isLoading">
<KvTabs @tab-changed="handleChange" v-if="loans.length > 1" class="tabs">
<KvTabs ref="tabs" @tab-changed="handleChange" v-if="loans.length > 1" class="tabs">
<template #tabNav>
<KvTab
v-for="(loan, index) in filteredLoans"
Expand Down Expand Up @@ -81,6 +81,7 @@
:multiple-slides-visible="true"
:slide-max-width="singleSlideWidth"
:embla-options="{ loop: false, align: 'center'}"
@change="onInteractCarousel"
>
<template v-for="(loan, index) in loans" #[`slide${index+1}`] :key="loan.id || index">
<BorrowerStatusCard :loan="loan" class="tw-h-full" />
Expand Down Expand Up @@ -153,6 +154,7 @@ const emit = defineEmits(['selected-loan']);
const { loans, totalLoans } = toRefs(props);
const carousel = ref(null);
const tabs = ref(null);
const windowWidth = ref(0);
const hasActiveLoans = computed(() => {
Expand Down Expand Up @@ -233,6 +235,10 @@ const handleResize = () => {
const throttledResize = _throttle(handleResize, 200);
const onInteractCarousel = interaction => {
tabs.value.tabContext.selectedIndex = interaction.value;
};
onMounted(() => {
if (!hasActiveLoans.value) {
$kvTrackEvent('portfolio', 'view', 'no-active-borrowers');
Expand Down

0 comments on commit a81108e

Please sign in to comment.