@ -4,7 +4,6 @@
< Swiper
v - if = "chunkList.length"
rewind
: autoplay = "chunkList.length > 1 ? { delay: 15000 } : false"
observer
observe - parents
observe - slide - children
@ -28,7 +27,7 @@
< / template >
< script setup lang = "ts" >
import { r ef, computed , onMounted , onBeforeUnmount } from 'vue'
import { shallowR ef, computed , onMounted , onBeforeUnmount } from 'vue'
import { chunk } from 'lodash-es'
import ScrollListItem from '@/components/ScrollListItem/ScrollListItem.vue'
import SwiperCore , { Autoplay } from 'swiper'
@ -51,27 +50,14 @@ const props = withDefaults(defineProps<Props>(), {
const chunkList = computed ( ( ) => chunk ( props . customerList , 6 ) )
const swiper = r ef( )
const swiper = shallowR ef( )
function swiperInit ( _swiper : any ) {
swiper . value = _swiper
}
function start ( ) {
swiper . value ? . autoplay ? . start ( )
}
function stop ( ) {
swiper . value ? . autoplay ? . stop ( )
}
onMounted ( ( ) => {
window . addEventListener ( 'touchend' , stop )
} )
onBeforeUnmount ( ( ) => {
window . removeEventListener ( 'touchend' , stop )
} )
defineExpose ( {
start
swiper
} )
< / script >