@rpg-engine/long-bow 0.5.66 → 0.5.67

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,10 +1,9 @@
1
1
  import React from 'react';
2
2
  export interface ISimpleImageCarousel {
3
- basePath: string;
4
- imagesSrc: string[];
3
+ images: string[];
5
4
  styles?: React.CSSProperties;
6
5
  autoCycle?: boolean;
7
6
  autoCycleDelay?: number;
8
7
  stopAutoCyclingOnInteraction?: boolean;
9
8
  }
10
- export declare const SimpleImageCarousel: ({ basePath, imagesSrc, styles, autoCycle, autoCycleDelay, stopAutoCyclingOnInteraction, }: ISimpleImageCarousel) => JSX.Element;
9
+ export declare const SimpleImageCarousel: React.FC<ISimpleImageCarousel>;
@@ -16015,8 +16015,7 @@ 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 basePath = _ref.basePath,
16019
- imagesSrc = _ref.imagesSrc,
16018
+ var images = _ref.images,
16020
16019
  styles = _ref.styles,
16021
16020
  _ref$autoCycle = _ref.autoCycle,
16022
16021
  autoCycle = _ref$autoCycle === void 0 ? false : _ref$autoCycle,
@@ -16027,42 +16026,43 @@ var SimpleImageCarousel = function SimpleImageCarousel(_ref) {
16027
16026
  var _useState = React.useState(0),
16028
16027
  currentImage = _useState[0],
16029
16028
  setCurrentImage = _useState[1];
16030
- var isInteracted = React.useRef(false);
16029
+ var _useState2 = React.useState(null),
16030
+ autoCycleId = _useState2[0],
16031
+ setAutoCycleId = _useState2[1];
16032
+ var handleLeftClick = function handleLeftClick() {
16033
+ setCurrentImage(function (prevImage) {
16034
+ return (prevImage - 1 + images.length) % images.length;
16035
+ });
16036
+ if (stopAutoCyclingOnInteraction && autoCycleId) {
16037
+ clearInterval(autoCycleId);
16038
+ setAutoCycleId(null);
16039
+ }
16040
+ };
16041
+ var handleRightClick = function handleRightClick() {
16042
+ setCurrentImage(function (prevImage) {
16043
+ return (prevImage + 1) % images.length;
16044
+ });
16045
+ if (stopAutoCyclingOnInteraction && autoCycleId) {
16046
+ clearInterval(autoCycleId);
16047
+ setAutoCycleId(null);
16048
+ }
16049
+ };
16031
16050
  React.useEffect(function () {
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);
16051
+ if (autoCycle) {
16052
+ var id = setInterval(function () {
16053
+ setCurrentImage(function (prevImage) {
16054
+ return (prevImage + 1) % images.length;
16055
+ });
16040
16056
  }, autoCycleDelay);
16057
+ setAutoCycleId(id);
16041
16058
  }
16042
16059
  return function () {
16043
- if (timer) {
16044
- clearInterval(timer);
16060
+ if (autoCycleId) {
16061
+ clearInterval(autoCycleId);
16045
16062
  }
16046
16063
  };
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;
16064
+ }, [autoCycle, autoCycleDelay, images.length]);
16065
+ var hasMoreThanOneImage = images.length > 1;
16066
16066
  return React__default.createElement(ImageContainer, {
16067
16067
  style: styles
16068
16068
  }, hasMoreThanOneImage && React__default.createElement(CustomLeftArrow, {
@@ -16073,8 +16073,8 @@ var SimpleImageCarousel = function SimpleImageCarousel(_ref) {
16073
16073
  onPointerDown: handleRightClick
16074
16074
  }), React__default.createElement(Carousel, null, React__default.createElement(FadeInCarouselImg, {
16075
16075
  key: currentImage,
16076
- src: basePath + "/" + imagesSrc[currentImage],
16077
- alt: imagesSrc[currentImage]
16076
+ src: images[currentImage],
16077
+ alt: "Image " + currentImage
16078
16078
  })));
16079
16079
  };
16080
16080
  var ImageContainer = /*#__PURE__*/styled__default.div.withConfig({