@rpg-engine/long-bow 0.5.71 → 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.
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
  export interface ISimpleImageCarousel {
3
- images: string[];
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: React.FC<ISimpleImageCarousel>;
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 images = _ref.images,
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 autoCycleId = React.useRef(null);
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
- if (autoCycle) {
16050
- autoCycleId.current = setInterval(function () {
16051
- setCurrentImage(function (prevImage) {
16052
- return (prevImage + 1) % (images == null ? void 0 : images.length);
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 (autoCycleId.current) {
16058
- clearInterval(autoCycleId.current);
16043
+ if (timer) {
16044
+ clearInterval(timer);
16059
16045
  }
16060
16046
  };
16061
- }, [autoCycle, autoCycleDelay, images == null ? void 0 : images.length]);
16062
- var hasMoreThanOneImage = (images == null ? void 0 : images.length) > 1;
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,14 +16073,14 @@ 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: images == null ? void 0 : images[currentImage],
16074
- alt: "Image " + currentImage
16076
+ src: basePath + "/" + imagesSrc[currentImage],
16077
+ alt: imagesSrc[currentImage]
16075
16078
  })));
16076
16079
  };
16077
16080
  var ImageContainer = /*#__PURE__*/styled__default.div.withConfig({
16078
16081
  displayName: "SimpleImageCarousel__ImageContainer",
16079
16082
  componentId: "sc-gdvbly-0"
16080
- })(["flex:1;display:flex;justify-content:center;align-items:center;height:100%;margin-right:0.5rem;max-width:400px;position:relative;width:400px;"]);
16083
+ })(["flex:1;display:flex;justify-content:center;align-items:center;height:100%;margin-right:0.5rem;max-width:400px;position:relative;"]);
16081
16084
  var CustomLeftArrow = /*#__PURE__*/styled__default(SelectArrow).withConfig({
16082
16085
  displayName: "SimpleImageCarousel__CustomLeftArrow",
16083
16086
  componentId: "sc-gdvbly-1"