@crystaldesign/widget-library 25.10.0-beta.12 → 25.10.0-beta.14
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/build/esm/index.js
CHANGED
|
@@ -861,6 +861,24 @@ function useGallery(_ref) {
|
|
|
861
861
|
setCurrentProductId(media.productId);
|
|
862
862
|
}
|
|
863
863
|
}
|
|
864
|
+
onThumbSlideChange(swiper.realIndex);
|
|
865
|
+
};
|
|
866
|
+
var onThumbSlideChange = function onThumbSlideChange(clickedIndex) {
|
|
867
|
+
if (!(thumbsSwiper !== null && thumbsSwiper !== void 0 && thumbsSwiper.slides)) return;
|
|
868
|
+
if (clickedIndex == null || clickedIndex < 0) return;
|
|
869
|
+
var visibleSlides = Array.from(thumbsSwiper.slides).filter(function (slide) {
|
|
870
|
+
return slide.classList.contains('swiper-slide-visible');
|
|
871
|
+
});
|
|
872
|
+
if (visibleSlides.length === 0) return;
|
|
873
|
+
var firstVisibleIndex = visibleSlides[0].swiperSlideIndex;
|
|
874
|
+
var lastVisibleIndex = visibleSlides[visibleSlides.length - 1].swiperSlideIndex;
|
|
875
|
+
|
|
876
|
+
// if the first or last visible slide is clicked, slide to the previous or next slide
|
|
877
|
+
if (clickedIndex === firstVisibleIndex) {
|
|
878
|
+
thumbsSwiper.slideTo(Math.max(clickedIndex - 1, 0));
|
|
879
|
+
} else if (clickedIndex === lastVisibleIndex) {
|
|
880
|
+
thumbsSwiper.slideTo(Math.min(clickedIndex + 1, thumbsSwiper.slides.length - 1));
|
|
881
|
+
}
|
|
864
882
|
};
|
|
865
883
|
return {
|
|
866
884
|
medias: medias,
|
|
@@ -870,7 +888,8 @@ function useGallery(_ref) {
|
|
|
870
888
|
currentIndex: currentMediaIndex,
|
|
871
889
|
setThumbsSwiper: setThumbsSwiper,
|
|
872
890
|
setSwiper: setSwiper,
|
|
873
|
-
onSlideChange: onSlideChange
|
|
891
|
+
onSlideChange: onSlideChange,
|
|
892
|
+
onThumbSlideChange: onThumbSlideChange
|
|
874
893
|
};
|
|
875
894
|
}
|
|
876
895
|
|
|
@@ -1306,7 +1325,8 @@ var Gallery = function Gallery(props) {
|
|
|
1306
1325
|
onSlideChange = _useGallery.onSlideChange,
|
|
1307
1326
|
setThumbsSwiper = _useGallery.setThumbsSwiper,
|
|
1308
1327
|
setSwiper = _useGallery.setSwiper,
|
|
1309
|
-
currentIndex = _useGallery.currentIndex
|
|
1328
|
+
currentIndex = _useGallery.currentIndex,
|
|
1329
|
+
onThumbSlideChange = _useGallery.onThumbSlideChange;
|
|
1310
1330
|
useEffect(function () {
|
|
1311
1331
|
if (props.setCurrentMedia) {
|
|
1312
1332
|
props.setCurrentMedia(medias[currentIndex]);
|
|
@@ -1365,6 +1385,9 @@ var Gallery = function Gallery(props) {
|
|
|
1365
1385
|
var _media$url;
|
|
1366
1386
|
return /*#__PURE__*/jsx(SwiperSlide, {
|
|
1367
1387
|
id: 'thumb media index ' + i,
|
|
1388
|
+
onClick: function onClick() {
|
|
1389
|
+
return onThumbSlideChange(i);
|
|
1390
|
+
},
|
|
1368
1391
|
children: /*#__PURE__*/jsx(Thumb, {
|
|
1369
1392
|
media: media,
|
|
1370
1393
|
medias: medias
|
|
@@ -9,5 +9,6 @@ export default function useGallery({ products, config: { functionTypes, add2DIma
|
|
|
9
9
|
setThumbsSwiper: import("react").Dispatch<import("react").SetStateAction<SwiperClass | null>>;
|
|
10
10
|
setSwiper: import("react").Dispatch<import("react").SetStateAction<SwiperClass | null>>;
|
|
11
11
|
onSlideChange: (swiper: SwiperClass) => void;
|
|
12
|
+
onThumbSlideChange: (clickedIndex: any) => void;
|
|
12
13
|
};
|
|
13
14
|
//# sourceMappingURL=useGallery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGallery.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Gallery/useGallery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAI9D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,QAAQ,EACR,MAAM,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,oBAAoB,EAAE,EAC3D,gBAAgB,EAChB,mBAAmB,GACpB,EAAE,YAAY;;;;;;;;4BAuCkB,WAAW;
|
|
1
|
+
{"version":3,"file":"useGallery.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Gallery/useGallery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAI9D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,QAAQ,EACR,MAAM,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,oBAAoB,EAAE,EAC3D,gBAAgB,EAChB,mBAAmB,GACpB,EAAE,YAAY;;;;;;;;4BAuCkB,WAAW;uCAoBA,GAAG;EA8B9C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crystaldesign/widget-library",
|
|
3
|
-
"version": "25.10.0-beta.
|
|
3
|
+
"version": "25.10.0-beta.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"storybook": "storybook dev -p 6006",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"suiteName": "widget-library",
|
|
37
37
|
"outputDirectory": "./test-reports"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "75cf583f53ed99d4242d919eaa52556a33cbab55"
|
|
40
40
|
}
|