33 <slot :currentSlide =" currentSlide" />
44
55 <!-- Navigation -->
6- <div class =" navigate" >
6+ <div v-if = " navigationEnabled " class =" navigate" >
77 <div class =" toggle-page left" @click =" prevSlide" >
88 <i class =" fas fa-chevron-left" ></i >
99 </div >
1313 </div >
1414
1515 <!-- Pagination -->
16- <div class =" pagination" >
16+ <div v-if = " paginationEnabled " class =" pagination" >
1717 <span
1818 v-for =" (slide, index) in getSlideCount"
1919 :key =" index"
2929import { ref , onMounted } from " vue" ;
3030
3131export default {
32- setup () {
32+ props: [" autoPlay" , " timeout" , " navigation" , " pagination" ],
33+ setup (props ) {
3334 const currentSlide = ref (1 );
3435 const getSlideCount = ref (null );
35- const autoPlayEnabled = ref (true );
36- const timeOutDuration = ref (5000 );
36+ const autoPlayEnabled = ref (
37+ props .autoPlay === undefined ? true : props .autoPlay
38+ );
39+ const timeOutDuration = ref (
40+ props .timeout === undefined ? 5000 : props .timeout
41+ );
42+ const paginationEnabled = ref (
43+ props .pagination === undefined ? true : props .pagination
44+ );
45+ const navigationEnabled = ref (
46+ props .navigation === undefined ? true : props .navigation
47+ );
3748
3849 const nextSlide = () => {
3950 if (currentSlide .value === getSlideCount .value ) {
@@ -55,14 +66,14 @@ export default {
5566 currentSlide .value = index + 1 ;
5667 };
5768
58- const autoPlay = () => {
69+ const startAutoPlay = () => {
5970 setInterval (() => {
6071 nextSlide ();
6172 }, timeOutDuration .value );
6273 };
6374
6475 if (autoPlayEnabled .value ) {
65- autoPlay ();
76+ startAutoPlay ();
6677 }
6778
6879 onMounted (() => {
@@ -75,6 +86,8 @@ export default {
7586 prevSlide,
7687 getSlideCount,
7788 goToSlide,
89+ paginationEnabled,
90+ navigationEnabled,
7891 };
7992 },
8093};
0 commit comments