Skip to content

Commit

Permalink
fix(Swiper): resolved click event invalid (#1064)
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao authored Aug 31, 2023
1 parent 8498e5b commit 159976c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/swiper/demos/base.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div style="padding: 0 16px">
<t-swiper :navigation="{ type: 'dots' }" :autoplay="false" @change="handleChange">
<t-swiper :navigation="{ type: 'dots' }" :autoplay="false" @click="handleClick" @change="handleChange">
<t-swiper-item v-for="(item, index) in swiperList" :key="index" style="height: 192px">
<img :src="item" class="img" />
</t-swiper-item>
Expand All @@ -20,6 +20,10 @@ const swiperList = [
const handleChange = (index: number, context: any) => {
console.log('基础示例,页数变化到》》》', index, context);
};
const handleClick = (value: number) => {
console.log('click: ', value);
};
</script>

<style>
Expand Down
2 changes: 1 addition & 1 deletion src/swiper/swiper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
height: containerHeight,
}"
@transitionend="handleAnimationEnd"
@click="onItemClick"
>
<slot />
</div>
Expand Down Expand Up @@ -173,6 +172,7 @@ const { lengthX, lengthY } = useSwipe(swiperContainer, {
passive: false,
onSwipeStart() {
if (disabled.value) return;
onItemClick(); // use touchstart to simulate click on swipe start
stopAutoplay();
},
onSwipe(e: TouchEvent) {
Expand Down

0 comments on commit 159976c

Please sign in to comment.