pds-dev-kit-web-test 2.7.544 → 2.7.545
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -26,6 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
29
|
+
/* eslint-disable no-loop-func */
|
|
30
|
+
/* eslint-disable no-plusplus */
|
|
29
31
|
var react_1 = require("react");
|
|
30
32
|
var swiper_1 = require("swiper");
|
|
31
33
|
require("swiper/modules/navigation/navigation.min.css");
|
|
@@ -44,40 +46,51 @@ function (_a, ref) {
|
|
|
44
46
|
}, [children]);
|
|
45
47
|
var finalSlidesPerView = props.effect === 'cards' ? 1 : slidesPerView;
|
|
46
48
|
var useAutoplay = !!styles.useAutoplay && childrenArray.length > 1;
|
|
47
|
-
// 2.
|
|
48
|
-
var
|
|
49
|
-
// 루프가 아니거나, slidesPerView가 1이하이면 원본 반환
|
|
50
|
-
console.log('loopedChildren calculation', {
|
|
51
|
-
loop: loop,
|
|
52
|
-
slidesPerView: slidesPerView,
|
|
53
|
-
originalChildrenLength: originalChildren.length
|
|
54
|
-
});
|
|
49
|
+
// 2. loop를 위한 슬라이드 배열 및 key 생성
|
|
50
|
+
var _b = (0, react_1.useMemo)(function () {
|
|
55
51
|
if (!loop || typeof slidesPerView !== 'number' || slidesPerView <= 1) {
|
|
56
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
slides: originalChildren.map(function (child, idx) { return ({ child: child, key: "original-".concat(idx) }); }),
|
|
54
|
+
shouldEnableLoop: loop
|
|
55
|
+
};
|
|
57
56
|
}
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
// loop를 위한 최소 슬라이드 수 계산 (Swiper 내부 복제를 위한 공간 확보)
|
|
58
|
+
var minSlidesForLoop = slidesPerView * 2;
|
|
59
|
+
// 슬라이드가 충분하면 원본 그대로 + loop 활성화
|
|
60
|
+
if (originalChildren.length >= minSlidesForLoop) {
|
|
61
|
+
return {
|
|
62
|
+
slides: originalChildren.map(function (child, idx) { return ({ child: child, key: "original-".concat(idx) }); }),
|
|
63
|
+
shouldEnableLoop: true
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// 슬라이드가 부족하면 충분한 개수까지 복제 + loop 활성화
|
|
67
|
+
if (originalChildren.length > 0) {
|
|
68
|
+
var duplicatedSlides_1 = [];
|
|
69
|
+
var copyCount_1 = 0;
|
|
70
|
+
// Swiper loop가 제대로 작동하려면 충분히 많이 복제
|
|
71
|
+
// minSlidesForLoop * 3 = 18개 정도면 무한 루프가 자연스럽게 작동
|
|
72
|
+
while (duplicatedSlides_1.length < minSlidesForLoop * 3) {
|
|
73
|
+
originalChildren.forEach(function (child, idx) {
|
|
74
|
+
duplicatedSlides_1.push({ child: child, key: "copy-".concat(copyCount_1, "-").concat(idx) });
|
|
75
|
+
});
|
|
76
|
+
copyCount_1++;
|
|
68
77
|
}
|
|
69
|
-
return
|
|
78
|
+
return {
|
|
79
|
+
slides: duplicatedSlides_1,
|
|
80
|
+
shouldEnableLoop: true // 충분히 복제했으므로 loop 활성화
|
|
81
|
+
};
|
|
70
82
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
83
|
+
return {
|
|
84
|
+
slides: originalChildren.map(function (child, idx) { return ({ child: child, key: "original-".concat(idx) }); }),
|
|
85
|
+
shouldEnableLoop: false
|
|
86
|
+
};
|
|
87
|
+
}, [originalChildren, loop, slidesPerView]), slides = _b.slides, shouldEnableLoop = _b.shouldEnableLoop;
|
|
88
|
+
// loopedSlides는 loop가 실제로 활성화될 때만 설정
|
|
75
89
|
var loopedSlidesCount = (0, react_1.useMemo)(function () {
|
|
76
|
-
if (!
|
|
90
|
+
if (!shouldEnableLoop || typeof slidesPerView !== 'number')
|
|
77
91
|
return undefined;
|
|
78
|
-
// slidesPerView를 기준으로 고정 (복제된 슬라이드 개수와 무관)
|
|
79
92
|
return slidesPerView;
|
|
80
|
-
}, [
|
|
93
|
+
}, [shouldEnableLoop, slidesPerView]);
|
|
81
94
|
return ((0, jsx_runtime_1.jsx)(StyledSwiper_1.default, __assign({ id: "styled-swiper-wrapper" }, { children: (0, jsx_runtime_1.jsx)(react_2.Swiper, __assign({ ref: ref, style: {
|
|
82
95
|
width: '100%',
|
|
83
96
|
height: '100%'
|
|
@@ -92,7 +105,10 @@ function (_a, ref) {
|
|
|
92
105
|
swiper_1.EffectCards,
|
|
93
106
|
swiper_1.EffectCoverflow,
|
|
94
107
|
swiper_1.EffectFlip
|
|
95
|
-
], loopedSlides: loopedSlidesCount, slidesPerView: finalSlidesPerView, scrollbar: styles.scrollbar, slidesPerGroup: styles.slidesPerGroup, spaceBetween: styles.spaceBetween, freeMode: styles.freeMode, autoplay: useAutoplay ? styles.autoplay : false, loop:
|
|
108
|
+
], loopedSlides: loopedSlidesCount, slidesPerView: finalSlidesPerView, scrollbar: styles.scrollbar, slidesPerGroup: styles.slidesPerGroup, spaceBetween: styles.spaceBetween, freeMode: styles.freeMode, autoplay: useAutoplay ? styles.autoplay : false, loop: shouldEnableLoop, allowTouchMove: allowTouchMove, observer: true, observeParents: true }, props, { children: slides.map(function (_a) {
|
|
109
|
+
var child = _a.child, key = _a.key;
|
|
110
|
+
return ((0, jsx_runtime_1.jsx)(react_2.SwiperSlide, __assign({ style: { pointerEvents: allowTouchMove ? 'auto' : 'none' } }, { children: child || (0, jsx_runtime_1.jsx)("div", { className: "swiper-slide-empty" }) }), key));
|
|
111
|
+
}) })) })));
|
|
96
112
|
});
|
|
97
113
|
ContentsCarouselCore.displayName = 'ContentsCarouselCore';
|
|
98
114
|
exports.default = ContentsCarouselCore;
|