yet-another-react-lightbox 3.12.0 → 3.12.2
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/index.d.ts +1 -1
- package/dist/index.js +9 -8
- package/dist/plugins/thumbnails/index.js +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -194,7 +194,7 @@ type ImageSlideProps = Partial<Pick<CarouselSettings, "imageFit" | "imageProps">
|
|
|
194
194
|
};
|
|
195
195
|
declare function ImageSlide({ slide: image, offset, render, rect, imageFit, imageProps, onClick, onLoad, style, }: ImageSlideProps): React.JSX.Element;
|
|
196
196
|
|
|
197
|
-
declare function Carousel({ carousel
|
|
197
|
+
declare function Carousel({ carousel }: ComponentProps): React.JSX.Element;
|
|
198
198
|
declare const CarouselModule: Module;
|
|
199
199
|
|
|
200
200
|
declare enum SwipeState {
|
package/dist/index.js
CHANGED
|
@@ -606,8 +606,8 @@ function ImageSlide({ slide: image, offset, render, rect, imageFit, imageProps,
|
|
|
606
606
|
}, []);
|
|
607
607
|
const cover = isImageFitCover(image, imageFit);
|
|
608
608
|
const nonInfinite = (value, fallback) => (Number.isFinite(value) ? value : fallback);
|
|
609
|
-
const maxWidth = nonInfinite(Math.max(...((_b = (_a = image.srcSet) === null || _a === void 0 ? void 0 : _a.map((x) => x.width)) !== null && _b !== void 0 ? _b : []).concat(image.width ? [image.width] : [])), ((_c = imageRef.current) === null || _c === void 0 ? void 0 : _c.naturalWidth) || 0);
|
|
610
|
-
const maxHeight = nonInfinite(Math.max(...((_e = (_d = image.srcSet) === null || _d === void 0 ? void 0 : _d.map((x) => x.height)) !== null && _e !== void 0 ? _e : []).concat(image.height ? [image.height] : [])), ((_f = imageRef.current) === null || _f === void 0 ? void 0 : _f.naturalHeight) || 0);
|
|
609
|
+
const maxWidth = nonInfinite(Math.max(...((_b = (_a = image.srcSet) === null || _a === void 0 ? void 0 : _a.map((x) => x.width)) !== null && _b !== void 0 ? _b : []).concat(image.width ? [image.width] : []).filter(Boolean)), ((_c = imageRef.current) === null || _c === void 0 ? void 0 : _c.naturalWidth) || 0);
|
|
610
|
+
const maxHeight = nonInfinite(Math.max(...((_e = (_d = image.srcSet) === null || _d === void 0 ? void 0 : _d.map((x) => x.height)) !== null && _e !== void 0 ? _e : []).concat(image.height ? [image.height] : []).filter(Boolean)), ((_f = imageRef.current) === null || _f === void 0 ? void 0 : _f.naturalHeight) || 0);
|
|
611
611
|
const defaultStyle = maxWidth && maxHeight
|
|
612
612
|
? {
|
|
613
613
|
maxWidth: `min(${maxWidth}px, 100%)`,
|
|
@@ -1174,21 +1174,22 @@ function Placeholder() {
|
|
|
1174
1174
|
const style = useLightboxProps().styles.slide;
|
|
1175
1175
|
return React.createElement("div", { className: cssClass("slide"), style: style });
|
|
1176
1176
|
}
|
|
1177
|
-
function Carousel({ carousel
|
|
1177
|
+
function Carousel({ carousel }) {
|
|
1178
1178
|
const { slides, currentIndex, globalIndex } = useLightboxState();
|
|
1179
1179
|
const { setCarouselRef } = useController();
|
|
1180
|
-
const spacingValue = parseLengthPercentage(spacing);
|
|
1181
|
-
const paddingValue = parseLengthPercentage(padding);
|
|
1180
|
+
const spacingValue = parseLengthPercentage(carousel.spacing);
|
|
1181
|
+
const paddingValue = parseLengthPercentage(carousel.padding);
|
|
1182
1182
|
const items = [];
|
|
1183
|
-
|
|
1183
|
+
const preload = Math.min(carousel.preload, Math.max(Math.floor(slides.length / 2), 1));
|
|
1184
|
+
if (hasSlides(slides)) {
|
|
1184
1185
|
for (let i = currentIndex - preload; i < currentIndex; i += 1) {
|
|
1185
1186
|
const key = globalIndex + i - currentIndex;
|
|
1186
|
-
items.push(!finite || i >= 0 ? (React.createElement(CarouselSlide, { key: key, slide: slides[(i + preload * slides.length) % slides.length], offset: i - currentIndex })) : (React.createElement(Placeholder, { key: key })));
|
|
1187
|
+
items.push(!carousel.finite || i >= 0 ? (React.createElement(CarouselSlide, { key: key, slide: slides[(i + preload * slides.length) % slides.length], offset: i - currentIndex })) : (React.createElement(Placeholder, { key: key })));
|
|
1187
1188
|
}
|
|
1188
1189
|
items.push(React.createElement(CarouselSlide, { key: globalIndex, slide: slides[currentIndex], offset: 0 }));
|
|
1189
1190
|
for (let i = currentIndex + 1; i <= currentIndex + preload; i += 1) {
|
|
1190
1191
|
const key = globalIndex + i - currentIndex;
|
|
1191
|
-
items.push(!finite || i <= slides.length - 1 ? (React.createElement(CarouselSlide, { key: key, slide: slides[i % slides.length], offset: i - currentIndex })) : (React.createElement(Placeholder, { key: key })));
|
|
1192
|
+
items.push(!carousel.finite || i <= slides.length - 1 ? (React.createElement(CarouselSlide, { key: key, slide: slides[i % slides.length], offset: i - currentIndex })) : (React.createElement(Placeholder, { key: key })));
|
|
1192
1193
|
}
|
|
1193
1194
|
}
|
|
1194
1195
|
return (React.createElement("div", { ref: setCarouselRef, className: clsx(cssClass(cssPrefix$2()), items.length > 0 && cssClass(cssPrefix$2("with_slides"))), style: {
|
|
@@ -121,7 +121,7 @@ function ThumbnailsTrack({ visible, containerRef }) {
|
|
|
121
121
|
});
|
|
122
122
|
React.useEffect(() => cleanup(subscribe(ACTION_SWIPE, handleControllerSwipe)), [subscribe, handleControllerSwipe]);
|
|
123
123
|
const { finite } = carousel;
|
|
124
|
-
const preload = Math.
|
|
124
|
+
const preload = Math.min(carousel.preload, Math.floor(slides.length / 2));
|
|
125
125
|
const items = [];
|
|
126
126
|
if (hasSlides(slides)) {
|
|
127
127
|
if (offset < 0) {
|
|
@@ -129,7 +129,7 @@ function ThumbnailsTrack({ visible, containerRef }) {
|
|
|
129
129
|
items.push({ slide: null, index: i, placeholder: true });
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
for (let i = index - preload - (offset
|
|
132
|
+
for (let i = index - preload - Math.max(offset, 0); i < index; i += 1) {
|
|
133
133
|
if (!(finite && i < 0)) {
|
|
134
134
|
items.push({ slide: getSlide(slides, i), index: i });
|
|
135
135
|
}
|
|
@@ -138,7 +138,7 @@ function ThumbnailsTrack({ visible, containerRef }) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
items.push({ slide: getSlide(slides, index), index });
|
|
141
|
-
for (let i = index + 1; i <= index + preload - (offset
|
|
141
|
+
for (let i = index + 1; i <= index + preload - Math.min(offset, 0); i += 1) {
|
|
142
142
|
if (!finite || i <= slides.length - 1) {
|
|
143
143
|
items.push({ slide: getSlide(slides, i), index: i });
|
|
144
144
|
}
|