@treely/strapi-slices 5.3.2 → 5.3.3
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/components/FullScreenImage/FullScreenImage.d.ts +3 -2
- package/dist/strapi-slices.cjs.development.js +31 -25
- package/dist/strapi-slices.cjs.development.js.map +1 -1
- package/dist/strapi-slices.cjs.production.min.js +1 -1
- package/dist/strapi-slices.cjs.production.min.js.map +1 -1
- package/dist/strapi-slices.esm.js +32 -26
- package/dist/strapi-slices.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FullScreenImage/FullScreenImage.tsx +29 -19
- package/src/slices/FullWidthImageSlider/FullWidthImageSlider.tsx +2 -1
|
@@ -4,6 +4,7 @@ export interface FullScreenImageProps {
|
|
|
4
4
|
images: StrapiImage[];
|
|
5
5
|
isOpen: boolean;
|
|
6
6
|
onClose: () => void;
|
|
7
|
-
|
|
7
|
+
currentIndex?: number;
|
|
8
|
+
setCurrentIndex?: (callback: (c: number) => number) => void;
|
|
8
9
|
}
|
|
9
|
-
export declare const FullScreenImage: ({ images, isOpen, onClose,
|
|
10
|
+
export declare const FullScreenImage: ({ images, isOpen, onClose, currentIndex, setCurrentIndex, }: FullScreenImageProps) => React.JSX.Element;
|
|
@@ -734,45 +734,50 @@ var FullScreenImage = function FullScreenImage(_ref) {
|
|
|
734
734
|
var images = _ref.images,
|
|
735
735
|
isOpen = _ref.isOpen,
|
|
736
736
|
onClose = _ref.onClose,
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
setImageIndex = _useState[1];
|
|
737
|
+
_ref$currentIndex = _ref.currentIndex,
|
|
738
|
+
currentIndex = _ref$currentIndex === void 0 ? 0 : _ref$currentIndex,
|
|
739
|
+
setCurrentIndex = _ref.setCurrentIndex;
|
|
741
740
|
var containerRef = React.useRef(null);
|
|
742
741
|
reactUse.useLockBodyScroll(isOpen);
|
|
743
|
-
var canMoveRight =
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
742
|
+
var canMoveRight = React.useMemo(function () {
|
|
743
|
+
return currentIndex < images.length - 1;
|
|
744
|
+
}, [currentIndex, images.length]);
|
|
745
|
+
var canMoveLeft = React.useMemo(function () {
|
|
746
|
+
return currentIndex !== 0;
|
|
747
|
+
}, [currentIndex]);
|
|
748
|
+
var onRight = React.useCallback(function () {
|
|
749
|
+
return canMoveRight && setCurrentIndex && setCurrentIndex(function (c) {
|
|
750
|
+
return c + 1;
|
|
748
751
|
});
|
|
749
|
-
};
|
|
750
|
-
var onLeft = function
|
|
751
|
-
return
|
|
752
|
-
return
|
|
752
|
+
}, [canMoveRight]);
|
|
753
|
+
var onLeft = React.useCallback(function () {
|
|
754
|
+
return canMoveLeft && setCurrentIndex && setCurrentIndex(function (c) {
|
|
755
|
+
return c - 1;
|
|
753
756
|
});
|
|
754
|
-
};
|
|
757
|
+
}, [canMoveLeft]);
|
|
755
758
|
reactUse.useKey('ArrowRight', onRight, {}, [onRight]);
|
|
756
759
|
reactUse.useKey('ArrowLeft', onLeft, {}, [onLeft]);
|
|
757
760
|
React.useEffect(function () {
|
|
758
|
-
if (
|
|
759
|
-
|
|
761
|
+
if (!!isOpen) {
|
|
762
|
+
setTimeout(function () {
|
|
763
|
+
var _containerRef$current;
|
|
764
|
+
containerRef == null || (_containerRef$current = containerRef.current) == null || _containerRef$current.scrollTo({
|
|
765
|
+
left: currentIndex * containerRef.current.clientWidth,
|
|
766
|
+
behavior: 'instant'
|
|
767
|
+
});
|
|
768
|
+
}, 10);
|
|
760
769
|
}
|
|
761
|
-
}, [
|
|
770
|
+
}, [isOpen]);
|
|
762
771
|
React.useEffect(function () {
|
|
763
772
|
if (containerRef.current) {
|
|
764
773
|
containerRef.current.scrollTo({
|
|
765
|
-
left:
|
|
774
|
+
left: currentIndex * containerRef.current.clientWidth,
|
|
766
775
|
behavior: 'smooth'
|
|
767
776
|
});
|
|
768
777
|
}
|
|
769
|
-
}, [
|
|
770
|
-
var onCloseLocal = function onCloseLocal() {
|
|
771
|
-
setImageIndex(0);
|
|
772
|
-
onClose();
|
|
773
|
-
};
|
|
778
|
+
}, [currentIndex, containerRef]);
|
|
774
779
|
return React__default.default.createElement(boemly.BoemlyModal, {
|
|
775
|
-
onClose:
|
|
780
|
+
onClose: onClose,
|
|
776
781
|
isOpen: isOpen,
|
|
777
782
|
title: "",
|
|
778
783
|
trigger: "",
|
|
@@ -3339,7 +3344,8 @@ var FullWidthImageSlider = function FullWidthImageSlider(_ref) {
|
|
|
3339
3344
|
images: slice.images.map(function (image) {
|
|
3340
3345
|
return image.img;
|
|
3341
3346
|
}),
|
|
3342
|
-
|
|
3347
|
+
currentIndex: sliderIndex,
|
|
3348
|
+
setCurrentIndex: setSliderIndex,
|
|
3343
3349
|
isOpen: isOpen,
|
|
3344
3350
|
onClose: function onClose() {
|
|
3345
3351
|
return setIsOpen(false);
|