@gem-sdk/components 2.0.0-dev.739 → 2.0.0-dev.740
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.
- package/dist/cjs/builder.js +2 -2
- package/dist/cjs/carousel/components/item/CarouselItem.js +1 -2
- package/dist/cjs/carousel/components/root/Carousel.liquid.js +3 -3
- package/dist/cjs/carousel/components/root/common/classes.js +2 -2
- package/dist/cjs/carousel/components/root/common/styles.js +0 -2
- package/dist/cjs/carousel/index.js +3 -3
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/product/components/product-images/ProductGalleryCarousel.js +2 -2
- package/dist/cjs/product/components/product-images/ProductImagesLightBox.js +2 -2
- package/dist/cjs/product/components/product-images-v2/ProductImagesV2.liquid.js +3 -3
- package/dist/cjs/product/components/product-images-v2/components/child/ProductFeaturedImageCarousel.js +2 -2
- package/dist/cjs/product/components/product-images-v2/components/gallery-carousel/GalleryCarousel.js +2 -2
- package/dist/cjs/product/components/product-images-v2/components/lightbox/ProductImagesLightBox.js +2 -2
- package/dist/cjs/product/components/product-list/ProductListCarouselLayout.js +2 -2
- package/dist/cjs/product/index.js +1 -1
- package/dist/esm/builder.js +2 -2
- package/dist/esm/carousel/components/item/CarouselItem.js +1 -2
- package/dist/esm/carousel/components/root/Carousel.liquid.js +3 -3
- package/dist/esm/carousel/components/root/common/classes.js +2 -2
- package/dist/esm/carousel/components/root/common/styles.js +0 -2
- package/dist/esm/carousel/index.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/product/components/product-images/ProductGalleryCarousel.js +2 -2
- package/dist/esm/product/components/product-images/ProductImagesLightBox.js +2 -2
- package/dist/esm/product/components/product-images-v2/ProductImagesV2.liquid.js +3 -3
- package/dist/esm/product/components/product-images-v2/components/child/ProductFeaturedImageCarousel.js +2 -2
- package/dist/esm/product/components/product-images-v2/components/gallery-carousel/GalleryCarousel.js +2 -2
- package/dist/esm/product/components/product-images-v2/components/lightbox/ProductImagesLightBox.js +2 -2
- package/dist/esm/product/components/product-list/ProductListCarouselLayout.js +2 -2
- package/dist/esm/product/index.js +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/cjs/carousel/components/root/CarouselWithSwiper.js +0 -131
- package/dist/cjs/carousel/components/root/CustomSwiper.js +0 -59
- package/dist/cjs/carousel/hooks/useCarouselWithSwiper.js +0 -343
- package/dist/esm/carousel/components/root/CarouselWithSwiper.js +0 -127
- package/dist/esm/carousel/components/root/CustomSwiper.js +0 -56
- package/dist/esm/carousel/hooks/useCarouselWithSwiper.js +0 -341
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useRef, useEffect } from 'react';
|
|
3
|
-
import { register } from 'swiper/element/bundle';
|
|
4
|
-
|
|
5
|
-
function Swiper(props) {
|
|
6
|
-
const swiperRef = useRef(null);
|
|
7
|
-
const { children, totalSlides, onSwiperReady, sliderClass, ...sliderSetting } = props;
|
|
8
|
-
const pauseOnMouseEnter = typeof props.autoplay === 'object' && props.autoplay !== null ? props.autoplay.pauseOnMouseEnter : undefined;
|
|
9
|
-
useEffect(()=>{
|
|
10
|
-
register();
|
|
11
|
-
Object.assign(swiperRef.current, sliderSetting);
|
|
12
|
-
swiperRef.current.initialize();
|
|
13
|
-
const instance = swiperRef.current.swiper;
|
|
14
|
-
onSwiperReady?.(instance);
|
|
15
|
-
}, []);
|
|
16
|
-
useEffect(()=>{
|
|
17
|
-
if (swiperRef.current?.swiper) {
|
|
18
|
-
const swiperInstance = swiperRef.current.swiper;
|
|
19
|
-
swiperInstance.destroy(true, true);
|
|
20
|
-
Object.assign(swiperRef.current, sliderSetting);
|
|
21
|
-
swiperRef.current.initialize();
|
|
22
|
-
onSwiperReady?.(swiperRef.current.swiper);
|
|
23
|
-
}
|
|
24
|
-
}, [
|
|
25
|
-
sliderSetting.dir,
|
|
26
|
-
sliderSetting.loop,
|
|
27
|
-
pauseOnMouseEnter,
|
|
28
|
-
sliderSetting.slidesPerView,
|
|
29
|
-
onSwiperReady,
|
|
30
|
-
totalSlides
|
|
31
|
-
]);
|
|
32
|
-
useEffect(()=>{
|
|
33
|
-
const swiperInstance = swiperRef.current?.swiper;
|
|
34
|
-
if (!swiperInstance) return;
|
|
35
|
-
Object.assign(swiperInstance.params, sliderSetting);
|
|
36
|
-
swiperInstance.update();
|
|
37
|
-
}, [
|
|
38
|
-
sliderSetting
|
|
39
|
-
]);
|
|
40
|
-
return /*#__PURE__*/ jsx("swiper-container", {
|
|
41
|
-
init: false,
|
|
42
|
-
className: sliderClass,
|
|
43
|
-
ref: swiperRef,
|
|
44
|
-
children: children
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
function SwiperSlide(props) {
|
|
48
|
-
const { children, className, ...rest } = props;
|
|
49
|
-
return /*#__PURE__*/ jsx("swiper-slide", {
|
|
50
|
-
...rest,
|
|
51
|
-
className: className,
|
|
52
|
-
children: children
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { Swiper, SwiperSlide };
|
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
import { useState, useMemo, useRef, useCallback, useImperativeHandle, useEffect } from 'react';
|
|
2
|
-
import { getResponsiveValueByScreen, useCurrentDevice, useEditorMode, useInteraction, DEVICES } from '@gem-sdk/core';
|
|
3
|
-
import useTrackPreviewPause from './useTrackPreviewPause.js';
|
|
4
|
-
|
|
5
|
-
const useCarouselWithSwiper = (props, ref, swiperInstance)=>{
|
|
6
|
-
const { builderProps, moveToIdx, styles, setting, isHiddenArrowWhenDisabled = true, elmRef, onClickArrow, onHandleChangeSlideByInteraction } = props;
|
|
7
|
-
const { loop, navigationEnable = {
|
|
8
|
-
desktop: true
|
|
9
|
-
}, navigationStyle } = setting ?? {};
|
|
10
|
-
const [totalSlideItem, setTotalSlideItem] = useState(0);
|
|
11
|
-
const [currentSlide, setCurrentSlide] = useState(setting?.defaultCurrentSlider ?? 0);
|
|
12
|
-
const isInfinity = useMemo(()=>{
|
|
13
|
-
return getResponsiveValueByScreen(loop, 'desktop', false);
|
|
14
|
-
}, [
|
|
15
|
-
loop
|
|
16
|
-
]);
|
|
17
|
-
const { isFirstPreviewClicked } = useTrackPreviewPause(setting?.runPreview);
|
|
18
|
-
// const { sliderSelector } = getData(props);
|
|
19
|
-
const localRef = useRef();
|
|
20
|
-
// const isRunningAnimation = useRef(false);
|
|
21
|
-
const previousIndex = useRef(moveToIdx ?? 0);
|
|
22
|
-
const isRenderDots = useMemo(()=>!!totalSlideItem && swiperInstance && getResponsiveValueByScreen(setting?.dot), [
|
|
23
|
-
swiperInstance,
|
|
24
|
-
setting?.dot,
|
|
25
|
-
totalSlideItem
|
|
26
|
-
]);
|
|
27
|
-
let delayTimeout;
|
|
28
|
-
const currentDevice = useCurrentDevice();
|
|
29
|
-
const mode = useEditorMode();
|
|
30
|
-
const { onListener, saveToElementInteractionData, getInteractionPreviousData, trigger } = useInteraction();
|
|
31
|
-
const getItemNumberFromOldData = useCallback(()=>{
|
|
32
|
-
if (!setting?.slidesToShow) return null;
|
|
33
|
-
const result = {};
|
|
34
|
-
DEVICES.forEach((device)=>{
|
|
35
|
-
const value = getResponsiveValueByScreen(setting?.slidesToShow, device);
|
|
36
|
-
result[device] = value ? value === 'auto' ? 4 : Math.floor(value) : 0;
|
|
37
|
-
});
|
|
38
|
-
return result;
|
|
39
|
-
}, [
|
|
40
|
-
setting?.slidesToShow
|
|
41
|
-
]);
|
|
42
|
-
const getSlideToShowFromOldData = useCallback(()=>{
|
|
43
|
-
if (!setting?.slidesToShow) return null;
|
|
44
|
-
const result = {};
|
|
45
|
-
DEVICES.forEach((device)=>{
|
|
46
|
-
const value = getResponsiveValueByScreen(setting?.slidesToShow, device);
|
|
47
|
-
result[device] = value ? value === 'auto' ? 4 : value : 0;
|
|
48
|
-
});
|
|
49
|
-
return result;
|
|
50
|
-
}, [
|
|
51
|
-
setting?.slidesToShow
|
|
52
|
-
]);
|
|
53
|
-
const showNavigation = useMemo(()=>{
|
|
54
|
-
const navigationEnableByDevice = getResponsiveValueByScreen(navigationEnable, currentDevice);
|
|
55
|
-
const navigationStyleByDevice = getResponsiveValueByScreen(navigationStyle, currentDevice);
|
|
56
|
-
return swiperInstance && navigationEnableByDevice && navigationStyleByDevice !== 'none';
|
|
57
|
-
}, [
|
|
58
|
-
swiperInstance,
|
|
59
|
-
navigationEnable,
|
|
60
|
-
navigationStyle,
|
|
61
|
-
currentDevice
|
|
62
|
-
]);
|
|
63
|
-
const slidesToShow = useMemo(()=>{
|
|
64
|
-
const oldData = getSlideToShowFromOldData();
|
|
65
|
-
if (oldData) {
|
|
66
|
-
return oldData;
|
|
67
|
-
}
|
|
68
|
-
const result = {};
|
|
69
|
-
DEVICES.forEach((device)=>{
|
|
70
|
-
const enableSneakPeak = getResponsiveValueByScreen(setting?.sneakPeak, device);
|
|
71
|
-
const offset = enableSneakPeak ? getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? getResponsiveValueByScreen(setting?.sneakPeakOffsetCenter, device) ?? 0 : getResponsiveValueByScreen(setting?.sneakPeakOffsetForward, device) ?? 0 : 0;
|
|
72
|
-
const rx = getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? -2 : -1;
|
|
73
|
-
const itemNumberByDevice = getResponsiveValueByScreen(setting?.itemNumber, device);
|
|
74
|
-
result[device] = typeof itemNumberByDevice === 'number' ? itemNumberByDevice + offset / 100 * rx : 'auto';
|
|
75
|
-
});
|
|
76
|
-
return result;
|
|
77
|
-
}, [
|
|
78
|
-
getSlideToShowFromOldData,
|
|
79
|
-
setting?.itemNumber,
|
|
80
|
-
setting?.sneakPeak,
|
|
81
|
-
setting?.sneakPeakOffsetCenter,
|
|
82
|
-
setting?.sneakPeakOffsetForward,
|
|
83
|
-
setting?.sneakPeakType
|
|
84
|
-
]);
|
|
85
|
-
const itemNumber = useMemo(()=>{
|
|
86
|
-
const oldData = getItemNumberFromOldData();
|
|
87
|
-
return oldData || setting?.itemNumber;
|
|
88
|
-
}, [
|
|
89
|
-
getItemNumberFromOldData,
|
|
90
|
-
setting?.itemNumber
|
|
91
|
-
]);
|
|
92
|
-
const getNumberOfFullWidthShow = useCallback((device)=>{
|
|
93
|
-
const sneakPeekTypeByNumber = getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? 2 : 1;
|
|
94
|
-
return typeof getResponsiveValueByScreen(itemNumber, device, 4) === 'number' ? getResponsiveValueByScreen(itemNumber, device, 4) - sneakPeekTypeByNumber : undefined;
|
|
95
|
-
}, [
|
|
96
|
-
setting?.sneakPeakType,
|
|
97
|
-
itemNumber
|
|
98
|
-
]);
|
|
99
|
-
const getItemsPerPage = ()=>{
|
|
100
|
-
const items = getResponsiveValueByScreen(slidesToShow, currentDevice, 1) === 'auto' ? 1 : getResponsiveValueByScreen(slidesToShow, currentDevice, 1);
|
|
101
|
-
return items ?? 1;
|
|
102
|
-
};
|
|
103
|
-
const getIndexSlideItemBy = (pageIdx)=>{
|
|
104
|
-
let indexPage = pageIdx * getItemsPerPage();
|
|
105
|
-
if (indexPage >= totalSlideItem - getItemsPerPage()) {
|
|
106
|
-
indexPage = totalSlideItem - getItemsPerPage();
|
|
107
|
-
}
|
|
108
|
-
return indexPage;
|
|
109
|
-
};
|
|
110
|
-
const getAllowTouchMove = (screen)=>{
|
|
111
|
-
const value = mode === 'edit' ? {
|
|
112
|
-
[screen]: false
|
|
113
|
-
} : setting?.enableDrag;
|
|
114
|
-
return getResponsiveValueByScreen(value, screen);
|
|
115
|
-
};
|
|
116
|
-
const handleDotClick = (idx, isLoop)=>{
|
|
117
|
-
const index = setting?.sneakPeak?.[currentDevice] ? idx : isLoop ? idx : getIndexSlideItemBy(idx);
|
|
118
|
-
swiperInstance?.slideToLoop(index);
|
|
119
|
-
previousIndex.current = index;
|
|
120
|
-
};
|
|
121
|
-
useImperativeHandle(ref, ()=>({
|
|
122
|
-
nextSlideInteraction,
|
|
123
|
-
previousSlideInteraction,
|
|
124
|
-
moveToSlideInteraction
|
|
125
|
-
}));
|
|
126
|
-
const dispatchEventSelectSlide = (index)=>{
|
|
127
|
-
trigger({
|
|
128
|
-
event: 'gp:rollback:select-slide',
|
|
129
|
-
selector: `[data-id="${builderProps?.uid}"]`,
|
|
130
|
-
element: elmRef?.current
|
|
131
|
-
});
|
|
132
|
-
trigger({
|
|
133
|
-
event: 'gp:select-slide',
|
|
134
|
-
selector: `[data-id="${builderProps?.uid}"]`,
|
|
135
|
-
data: index,
|
|
136
|
-
element: elmRef?.current
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
const moveToIdxInteraction = (idx)=>{
|
|
140
|
-
swiperInstance?.slideTo(idx);
|
|
141
|
-
onHandleChangeSlideByInteraction && onHandleChangeSlideByInteraction(idx);
|
|
142
|
-
};
|
|
143
|
-
const handleDirectionalSlide = (params, direction)=>{
|
|
144
|
-
const { key, data, isRollback, element } = params;
|
|
145
|
-
const currentIndex = Math.max(swiperInstance?.activeIndex ?? 0, 0);
|
|
146
|
-
if (isRollback && data === undefined) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
if (isRollback) {
|
|
150
|
-
if (direction === 'specific') {
|
|
151
|
-
const { previousData } = getInteractionPreviousData(element, key);
|
|
152
|
-
moveToIdxInteraction(Number(previousData));
|
|
153
|
-
} else {
|
|
154
|
-
// For next/previous, move in opposite direction during rollback
|
|
155
|
-
const newIndex = direction === 'next' ? currentIndex - 1 : currentIndex + 1;
|
|
156
|
-
moveToIdxInteraction(newIndex);
|
|
157
|
-
}
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
// Save current state and move to new position
|
|
161
|
-
const indexToSave = direction === 'specific' ? Math.max(previousIndex.current, 0) : currentIndex;
|
|
162
|
-
saveToElementInteractionData(element, key, indexToSave.toString());
|
|
163
|
-
const targetIndex = direction === 'specific' ? Number(data) : direction === 'next' ? currentIndex + 1 : currentIndex - 1;
|
|
164
|
-
moveToIdxInteraction(targetIndex);
|
|
165
|
-
};
|
|
166
|
-
const nextSlideInteraction = (params)=>{
|
|
167
|
-
handleDirectionalSlide(params, 'next');
|
|
168
|
-
};
|
|
169
|
-
const previousSlideInteraction = (params)=>{
|
|
170
|
-
handleDirectionalSlide(params, 'previous');
|
|
171
|
-
};
|
|
172
|
-
const moveToSlideInteraction = (params)=>{
|
|
173
|
-
handleDirectionalSlide(params, 'specific');
|
|
174
|
-
};
|
|
175
|
-
const slidesPerView = getItemsPerPage();
|
|
176
|
-
const sliderSettings = useMemo(()=>{
|
|
177
|
-
return {
|
|
178
|
-
speed: styles?.playSpeed === 0 ? 1 : styles?.playSpeed ?? 500,
|
|
179
|
-
dir: setting?.rtl ? 'rtl' : 'ltr',
|
|
180
|
-
slidesPerView,
|
|
181
|
-
spaceBetween: getResponsiveValueByScreen(styles?.spacing, currentDevice),
|
|
182
|
-
loop: getResponsiveValueByScreen(loop, currentDevice, false),
|
|
183
|
-
breakpoints: {
|
|
184
|
-
0: {
|
|
185
|
-
allowTouchMove: getAllowTouchMove('mobile'),
|
|
186
|
-
centeredSlides: getResponsiveValueByScreen(setting?.sneakPeakType, 'mobile') === 'center'
|
|
187
|
-
},
|
|
188
|
-
768: {
|
|
189
|
-
allowTouchMove: getAllowTouchMove('tablet'),
|
|
190
|
-
centeredSlides: getResponsiveValueByScreen(setting?.sneakPeakType, 'tablet') === 'center'
|
|
191
|
-
},
|
|
192
|
-
1025: {
|
|
193
|
-
allowTouchMove: getAllowTouchMove('desktop'),
|
|
194
|
-
centeredSlides: getResponsiveValueByScreen(setting?.sneakPeakType, 'desktop') === 'center'
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
autoplay: {
|
|
198
|
-
delay: (setting?.autoplayTimeout ?? 1) * 1000,
|
|
199
|
-
pauseOnMouseEnter: setting?.pauseOnHover
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
}, [
|
|
203
|
-
styles?.playSpeed,
|
|
204
|
-
setting?.rtl,
|
|
205
|
-
styles?.spacing,
|
|
206
|
-
currentDevice,
|
|
207
|
-
loop,
|
|
208
|
-
slidesPerView,
|
|
209
|
-
setting?.sneakPeakType,
|
|
210
|
-
setting?.pauseOnHover,
|
|
211
|
-
setting?.autoplayTimeout
|
|
212
|
-
]);
|
|
213
|
-
useEffect(()=>{
|
|
214
|
-
const selector = `[data-id="${builderProps?.uid}"]`;
|
|
215
|
-
onListener({
|
|
216
|
-
event: 'gp:change-next-slide',
|
|
217
|
-
selector,
|
|
218
|
-
elementRef: localRef
|
|
219
|
-
}, (params)=>{
|
|
220
|
-
const { data, isRollback, uniqueStorageKey } = params || {};
|
|
221
|
-
nextSlideInteraction({
|
|
222
|
-
element: localRef.current,
|
|
223
|
-
data,
|
|
224
|
-
isRollback,
|
|
225
|
-
key: uniqueStorageKey
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
onListener({
|
|
229
|
-
event: 'gp:change-previous-slide',
|
|
230
|
-
selector,
|
|
231
|
-
elementRef: localRef
|
|
232
|
-
}, (params)=>{
|
|
233
|
-
const { data, isRollback, uniqueStorageKey } = params || {};
|
|
234
|
-
previousSlideInteraction({
|
|
235
|
-
element: localRef.current,
|
|
236
|
-
data,
|
|
237
|
-
isRollback,
|
|
238
|
-
key: uniqueStorageKey
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
onListener({
|
|
242
|
-
event: 'gp:change-image-step',
|
|
243
|
-
selector,
|
|
244
|
-
elementRef: localRef
|
|
245
|
-
}, (params)=>{
|
|
246
|
-
const { data, isRollback, uniqueStorageKey } = params || {};
|
|
247
|
-
moveToSlideInteraction({
|
|
248
|
-
element: localRef.current,
|
|
249
|
-
data,
|
|
250
|
-
isRollback,
|
|
251
|
-
key: uniqueStorageKey
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
onListener({
|
|
255
|
-
event: 'gp:change-index-slide',
|
|
256
|
-
selector
|
|
257
|
-
}, (params)=>{
|
|
258
|
-
const element = document.querySelector(selector);
|
|
259
|
-
const { data, isRollback, uniqueStorageKey } = params || {};
|
|
260
|
-
moveToSlideInteraction({
|
|
261
|
-
element,
|
|
262
|
-
data,
|
|
263
|
-
isRollback,
|
|
264
|
-
key: uniqueStorageKey
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
}, []);
|
|
268
|
-
const handleNextAndPrevSlide = (action)=>{
|
|
269
|
-
action === 'next' ? swiperInstance?.slideNext() : swiperInstance?.slidePrev();
|
|
270
|
-
if (onClickArrow) {
|
|
271
|
-
delayTimeout && clearTimeout(delayTimeout);
|
|
272
|
-
delayTimeout = setTimeout(()=>onClickArrow && onClickArrow(), 500);
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
useEffect(()=>{
|
|
276
|
-
if (typeof moveToIdx == 'number') {
|
|
277
|
-
previousIndex.current = moveToIdx;
|
|
278
|
-
swiperInstance?.slideTo(moveToIdx);
|
|
279
|
-
}
|
|
280
|
-
}, [
|
|
281
|
-
swiperInstance,
|
|
282
|
-
moveToIdx,
|
|
283
|
-
isHiddenArrowWhenDisabled
|
|
284
|
-
]);
|
|
285
|
-
useEffect(()=>{
|
|
286
|
-
if (!swiperInstance) return;
|
|
287
|
-
const updateState = ()=>{
|
|
288
|
-
const { realIndex, slides } = swiperInstance;
|
|
289
|
-
setCurrentSlide(realIndex);
|
|
290
|
-
setTotalSlideItem(slides?.length);
|
|
291
|
-
};
|
|
292
|
-
updateState();
|
|
293
|
-
swiperInstance.on('slideChange', updateState);
|
|
294
|
-
return ()=>{
|
|
295
|
-
swiperInstance?.off('slideChange', updateState);
|
|
296
|
-
};
|
|
297
|
-
}, [
|
|
298
|
-
swiperInstance
|
|
299
|
-
]);
|
|
300
|
-
useEffect(()=>{
|
|
301
|
-
if (swiperInstance?.wrapperEl) {
|
|
302
|
-
swiperInstance.wrapperEl.style.transitionTimingFunction = setting?.animationMode ?? 'ease';
|
|
303
|
-
}
|
|
304
|
-
}, [
|
|
305
|
-
swiperInstance,
|
|
306
|
-
setting?.animationMode
|
|
307
|
-
]);
|
|
308
|
-
useEffect(()=>{
|
|
309
|
-
if (!swiperInstance) return;
|
|
310
|
-
if (swiperInstance.autoplay) {
|
|
311
|
-
const shouldRunAutoplay = mode === 'edit' ? isFirstPreviewClicked ? setting?.runPreview && setting?.autoplay : false : setting?.autoplay;
|
|
312
|
-
if (shouldRunAutoplay) {
|
|
313
|
-
swiperInstance.autoplay.start();
|
|
314
|
-
} else {
|
|
315
|
-
swiperInstance.autoplay.stop();
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}, [
|
|
319
|
-
swiperInstance,
|
|
320
|
-
setting?.autoplay,
|
|
321
|
-
mode,
|
|
322
|
-
isFirstPreviewClicked,
|
|
323
|
-
setting?.runPreview
|
|
324
|
-
]);
|
|
325
|
-
return {
|
|
326
|
-
isInfinity,
|
|
327
|
-
sliderSettings,
|
|
328
|
-
totalSlideItem,
|
|
329
|
-
currentSlide,
|
|
330
|
-
localRef,
|
|
331
|
-
isRenderDots,
|
|
332
|
-
showNavigation,
|
|
333
|
-
handleDotClick,
|
|
334
|
-
getItemsPerPage,
|
|
335
|
-
handleNextAndPrevSlide,
|
|
336
|
-
dispatchEventSelectSlide,
|
|
337
|
-
getNumberOfFullWidthShow
|
|
338
|
-
};
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
export { useCarouselWithSwiper };
|