Skip to content

Commit

Permalink
feat(vue): useSwiper and useSwiperSlide context hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Feb 1, 2022
1 parent e52de28 commit 987a32e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/vue/context.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { inject } from 'vue';

export const useSwiperSlide = () => {
return inject('swiperSlide');
};

export const useSwiper = () => {
return inject('swiper');
};
13 changes: 11 additions & 2 deletions src/vue/swiper-vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
FreeModeOptions,
GridOptions,
} from '../types';
import { ComponentOptionsMixin, DefineComponent, PropType } from 'vue';
import { ComponentOptionsMixin, DefineComponent, PropType, Ref } from 'vue';
import { SwiperOptions, Swiper as SwiperClass } from '../types';

declare const Swiper: DefineComponent<
Expand Down Expand Up @@ -479,4 +479,13 @@ declare const SwiperSlide: DefineComponent<{
};
}>;

export { Swiper, SwiperSlide };
declare const useSwiper: () => Ref<SwiperClass>;
declare const useSwiperSlide: () => Ref<{
isActive: boolean;
isVisible: boolean;
isDuplicate: boolean;
isPrev: boolean;
isNext: boolean;
}>;

export { Swiper, SwiperSlide, useSwiper, useSwiperSlide };
2 changes: 2 additions & 0 deletions src/vue/swiper-vue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Swiper } from './swiper.js';
import { SwiperSlide } from './swiper-slide.js';

export { useSwiperSlide, useSwiper } from './context.js';

export { Swiper, SwiperSlide };

0 comments on commit 987a32e

Please sign in to comment.