fix: [디자인QA] 슬라이드 인덱스 전환 시 영상이 처음부터 재생되도록 적용
This commit is contained in:
@@ -21,6 +21,8 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
|
||||
const emit = defineEmits(['mounted', 'move', 'arrowClick'])
|
||||
|
||||
const splideIndex = defineModel<number>('index', { required: false })
|
||||
|
||||
// Splide 화살표 로직을 위한 composable 사용
|
||||
const { addArrowClickListeners } = useSplideArrow()
|
||||
|
||||
@@ -88,6 +90,14 @@ const getThumbnailSrc = (item: PageDataResourceGroup) => {
|
||||
return getResourceSrc(item)
|
||||
}
|
||||
|
||||
const handleSplideMounted = (splide: SplideType) => {
|
||||
emit('mounted', splide)
|
||||
|
||||
if (splideIndex.value !== undefined) {
|
||||
splideIndex.value = splide.index
|
||||
}
|
||||
}
|
||||
|
||||
const handleMove = (
|
||||
splide: SplideType,
|
||||
newIndex: number,
|
||||
@@ -95,10 +105,10 @@ const handleMove = (
|
||||
destIndex: number
|
||||
) => {
|
||||
emit('move', splide, newIndex, oldIndex, destIndex)
|
||||
}
|
||||
|
||||
const handleSplideMounted = (splide: SplideType) => {
|
||||
emit('mounted', splide)
|
||||
if (splideIndex.value !== undefined) {
|
||||
splideIndex.value = newIndex
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -141,8 +151,8 @@ onBeforeUnmount(() => {
|
||||
ref="mainRef"
|
||||
:options="mainOptions"
|
||||
class="main-splide"
|
||||
@splide:move="handleMove"
|
||||
@splide:mounted="handleSplideMounted"
|
||||
@splide:move="handleMove"
|
||||
>
|
||||
<slot />
|
||||
</Splide>
|
||||
|
||||
Reference in New Issue
Block a user