@rpg-engine/long-bow 0.5.68 → 0.5.71

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.5.68",
3
+ "version": "0.5.71",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
2
  import styled, { keyframes } from 'styled-components';
3
3
  import SelectArrow from '../Arrow/SelectArrow';
4
4
 
@@ -18,37 +18,36 @@ export const SimpleImageCarousel: React.FC<ISimpleImageCarousel> = ({
18
18
  stopAutoCyclingOnInteraction = false,
19
19
  }) => {
20
20
  const [currentImage, setCurrentImage] = useState(0);
21
- const [autoCycleId, setAutoCycleId] = useState<NodeJS.Timeout | null>(null);
21
+ const autoCycleId = useRef<NodeJS.Timeout | null>(null);
22
22
 
23
23
  const handleLeftClick = () => {
24
24
  setCurrentImage(
25
25
  prevImage => (prevImage - 1 + images?.length) % images?.length
26
26
  );
27
- if (stopAutoCyclingOnInteraction && autoCycleId) {
28
- clearInterval(autoCycleId);
29
- setAutoCycleId(null);
27
+ if (stopAutoCyclingOnInteraction && autoCycleId.current) {
28
+ clearInterval(autoCycleId.current);
29
+ autoCycleId.current = null;
30
30
  }
31
31
  };
32
32
 
33
33
  const handleRightClick = () => {
34
34
  setCurrentImage(prevImage => (prevImage + 1) % images?.length);
35
- if (stopAutoCyclingOnInteraction && autoCycleId) {
36
- clearInterval(autoCycleId);
37
- setAutoCycleId(null);
35
+ if (stopAutoCyclingOnInteraction && autoCycleId.current) {
36
+ clearInterval(autoCycleId.current);
37
+ autoCycleId.current = null;
38
38
  }
39
39
  };
40
40
 
41
41
  useEffect(() => {
42
42
  if (autoCycle) {
43
- const id = setInterval(() => {
43
+ autoCycleId.current = setInterval(() => {
44
44
  setCurrentImage(prevImage => (prevImage + 1) % images?.length);
45
45
  }, autoCycleDelay);
46
- setAutoCycleId(id);
47
46
  }
48
47
 
49
48
  return () => {
50
- if (autoCycleId) {
51
- clearInterval(autoCycleId);
49
+ if (autoCycleId.current) {
50
+ clearInterval(autoCycleId.current);
52
51
  }
53
52
  };
54
53
  }, [autoCycle, autoCycleDelay, images?.length]);
@@ -83,6 +82,7 @@ const ImageContainer = styled.div`
83
82
  margin-right: 0.5rem;
84
83
  max-width: 400px;
85
84
  position: relative;
85
+ width: 400px;
86
86
  `;
87
87
 
88
88
  const CustomLeftArrow = styled(SelectArrow)`