Skip to content

Commit

Permalink
Merge pull request #5679 from kiva/change-tab-on-carousel-swipe-MP-1035
Browse files Browse the repository at this point in the history
feat: change tab on swipe borrower carousel in my kiva page
  • Loading branch information
christian14b authored Nov 12, 2024
2 parents c725082 + a81108e commit e2b7da2
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 e2b7da2

Please sign in to comment.