fix. 코드 리팩토링

This commit is contained in:
clkim
2025-10-21 13:58:18 +09:00
parent fdf1d9175c
commit a702a0898f
6 changed files with 34 additions and 45 deletions

View File

@@ -19,7 +19,7 @@ const props = withDefaults(defineProps<Props>(), {
drag: true,
})
const emit = defineEmits(['arrowClick'])
const emit = defineEmits(['mounted', 'move', 'arrowClick'])
// Splide 화살표 로직을 위한 composable 사용
const { addArrowClickListeners } = useSplideArrow()
@@ -85,6 +85,19 @@ const getThumbnailSrc = (item: PageDataTemplateComponentSet) => {
: pagenaviThumbnailSrc?.pcSrc || ''
}
const handleMove = (
splide: SplideType,
newIndex: number,
oldIndex: number,
destIndex: number
) => {
emit('move', splide, newIndex, oldIndex, destIndex)
}
const handleSplideMounted = (splide: SplideType) => {
emit('mounted', splide)
}
onMounted(() => {
mainInst = mainRef.value?.splide ?? null
thumbsInst = thumbsRef.value?.splide ?? null
@@ -110,7 +123,13 @@ onBeforeUnmount(() => {
<template>
<div :class="['thumbnail-carousel', $attrs?.class, `thumbnail-${variant}`]">
<!-- 메인 슬라이드 -->
<Splide ref="mainRef" :options="mainOptions" class="main-splide">
<Splide
ref="mainRef"
:options="mainOptions"
class="main-splide"
@splide:move="handleMove"
@splide:mounted="handleSplideMounted"
>
<slot />
</Splide>
<!-- 썸네일 슬라이드 -->