Skip to content

Commit

Permalink
feat(Swiper): add two new informal event funs
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Jun 7, 2024
1 parent 8be68bb commit 9fd2bc6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/swiper/swiper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const navName = `${prefix}-swiper-nav`;
export default defineComponent({
name,
props,
emits: ['change', 'update:current', 'update:modelValue'],
emits: ['change', 'update:current', 'update:modelValue', 'transitionenter', 'transitionleave'],
setup(props, context) {
const swiperClass = usePrefixClass('swiper');
const readerTNodeJSX = useTNodeJSX();
Expand Down Expand Up @@ -175,6 +175,14 @@ export default defineComponent({
startAutoplay();
};

const onTransitionstart = (event: TransitionEvent) => {
context.emit('transitionenter', event);
};

const onTransitionend = (event: TransitionEvent) => {
context.emit('transitionleave', event);
};

const addChild = (item: any) => {
items.value.push(item);
};
Expand Down Expand Up @@ -319,8 +327,10 @@ export default defineComponent({
transform: translateContainer.value,
height: containerHeight.value,
}}
onTransitionstart={onTransitionstart}
onTransitionend={(event: TransitionEvent) => {
if (event.target === event.currentTarget) {
onTransitionend(event);
handleAnimationEnd();
}
}}
Expand Down

0 comments on commit 9fd2bc6

Please sign in to comment.