@rpg-engine/long-bow 0.5.70 → 0.5.72
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/ImageCarousel/SimpleImageCarousel.d.ts +3 -2
- package/dist/long-bow.cjs.development.js +34 -31
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +34 -31
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ImageCarousel/SimpleImageCarousel.tsx +39 -31
- package/src/stories/SimpleImageCarousel.stories.tsx +2 -3
- package/src/assets/images/backpack.png +0 -0
- package/src/assets/images/depot.png +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface ISimpleImageCarousel {
|
|
3
|
-
|
|
3
|
+
basePath: string;
|
|
4
|
+
imagesSrc: string[];
|
|
4
5
|
styles?: React.CSSProperties;
|
|
5
6
|
autoCycle?: boolean;
|
|
6
7
|
autoCycleDelay?: number;
|
|
7
8
|
stopAutoCyclingOnInteraction?: boolean;
|
|
8
9
|
}
|
|
9
|
-
export declare const SimpleImageCarousel:
|
|
10
|
+
export declare const SimpleImageCarousel: ({ basePath, imagesSrc, styles, autoCycle, autoCycleDelay, stopAutoCyclingOnInteraction, }: ISimpleImageCarousel) => JSX.Element;
|
|
@@ -16015,7 +16015,8 @@ var CloseButton$3 = /*#__PURE__*/styled__default.div.withConfig({
|
|
|
16015
16015
|
})(["position:absolute;top:3px;right:0px;color:white;z-index:22;font-size:1.5rem;@media (max-width:950px){font-size:1.7rem;padding:12px;}"]);
|
|
16016
16016
|
|
|
16017
16017
|
var SimpleImageCarousel = function SimpleImageCarousel(_ref) {
|
|
16018
|
-
var
|
|
16018
|
+
var basePath = _ref.basePath,
|
|
16019
|
+
imagesSrc = _ref.imagesSrc,
|
|
16019
16020
|
styles = _ref.styles,
|
|
16020
16021
|
_ref$autoCycle = _ref.autoCycle,
|
|
16021
16022
|
autoCycle = _ref$autoCycle === void 0 ? false : _ref$autoCycle,
|
|
@@ -16026,40 +16027,42 @@ var SimpleImageCarousel = function SimpleImageCarousel(_ref) {
|
|
|
16026
16027
|
var _useState = React.useState(0),
|
|
16027
16028
|
currentImage = _useState[0],
|
|
16028
16029
|
setCurrentImage = _useState[1];
|
|
16029
|
-
var
|
|
16030
|
-
var handleLeftClick = function handleLeftClick() {
|
|
16031
|
-
setCurrentImage(function (prevImage) {
|
|
16032
|
-
return (prevImage - 1 + (images == null ? void 0 : images.length)) % (images == null ? void 0 : images.length);
|
|
16033
|
-
});
|
|
16034
|
-
if (stopAutoCyclingOnInteraction && autoCycleId.current) {
|
|
16035
|
-
clearInterval(autoCycleId.current);
|
|
16036
|
-
autoCycleId.current = null;
|
|
16037
|
-
}
|
|
16038
|
-
};
|
|
16039
|
-
var handleRightClick = function handleRightClick() {
|
|
16040
|
-
setCurrentImage(function (prevImage) {
|
|
16041
|
-
return (prevImage + 1) % (images == null ? void 0 : images.length);
|
|
16042
|
-
});
|
|
16043
|
-
if (stopAutoCyclingOnInteraction && autoCycleId.current) {
|
|
16044
|
-
clearInterval(autoCycleId.current);
|
|
16045
|
-
autoCycleId.current = null;
|
|
16046
|
-
}
|
|
16047
|
-
};
|
|
16030
|
+
var isInteracted = React.useRef(false);
|
|
16048
16031
|
React.useEffect(function () {
|
|
16049
|
-
|
|
16050
|
-
|
|
16051
|
-
|
|
16052
|
-
|
|
16053
|
-
|
|
16032
|
+
var timer = null;
|
|
16033
|
+
if (autoCycle && !isInteracted.current) {
|
|
16034
|
+
timer = setInterval(function () {
|
|
16035
|
+
if (stopAutoCyclingOnInteraction && isInteracted.current) {
|
|
16036
|
+
clearInterval(timer);
|
|
16037
|
+
return;
|
|
16038
|
+
}
|
|
16039
|
+
handleRightClick(true);
|
|
16054
16040
|
}, autoCycleDelay);
|
|
16055
16041
|
}
|
|
16056
16042
|
return function () {
|
|
16057
|
-
if (
|
|
16058
|
-
clearInterval(
|
|
16043
|
+
if (timer) {
|
|
16044
|
+
clearInterval(timer);
|
|
16059
16045
|
}
|
|
16060
16046
|
};
|
|
16061
|
-
}, [autoCycle, autoCycleDelay
|
|
16062
|
-
var
|
|
16047
|
+
}, [autoCycle, autoCycleDelay]);
|
|
16048
|
+
var handleLeftClick = function handleLeftClick() {
|
|
16049
|
+
isInteracted.current = true;
|
|
16050
|
+
setCurrentImage(function (oldImage) {
|
|
16051
|
+
return oldImage === 0 ? imagesSrc.length - 1 : oldImage - 1;
|
|
16052
|
+
});
|
|
16053
|
+
};
|
|
16054
|
+
var handleRightClick = function handleRightClick(isAutomatedClick) {
|
|
16055
|
+
if (isAutomatedClick === void 0) {
|
|
16056
|
+
isAutomatedClick = false;
|
|
16057
|
+
}
|
|
16058
|
+
if (!isAutomatedClick) {
|
|
16059
|
+
isInteracted.current = true;
|
|
16060
|
+
}
|
|
16061
|
+
setCurrentImage(function (oldImage) {
|
|
16062
|
+
return oldImage === imagesSrc.length - 1 ? 0 : oldImage + 1;
|
|
16063
|
+
});
|
|
16064
|
+
};
|
|
16065
|
+
var hasMoreThanOneImage = imagesSrc.length > 1;
|
|
16063
16066
|
return React__default.createElement(ImageContainer, {
|
|
16064
16067
|
style: styles
|
|
16065
16068
|
}, hasMoreThanOneImage && React__default.createElement(CustomLeftArrow, {
|
|
@@ -16070,8 +16073,8 @@ var SimpleImageCarousel = function SimpleImageCarousel(_ref) {
|
|
|
16070
16073
|
onPointerDown: handleRightClick
|
|
16071
16074
|
}), React__default.createElement(Carousel, null, React__default.createElement(FadeInCarouselImg, {
|
|
16072
16075
|
key: currentImage,
|
|
16073
|
-
src:
|
|
16074
|
-
alt:
|
|
16076
|
+
src: basePath + "/" + imagesSrc[currentImage],
|
|
16077
|
+
alt: imagesSrc[currentImage]
|
|
16075
16078
|
})));
|
|
16076
16079
|
};
|
|
16077
16080
|
var ImageContainer = /*#__PURE__*/styled__default.div.withConfig({
|