@gem-sdk/components 2.1.13-staging.21 → 2.1.13-staging.22
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/cjs/product/components/ProductImagesV2/jsx/components/ProductFeaturedImageCarousel.js
CHANGED
|
@@ -20,12 +20,20 @@ const ProductFeaturedImageCarousel = ({ productImages, imgRef, onHandleClick, on
|
|
|
20
20
|
const { onListener, ref } = core.useInteraction();
|
|
21
21
|
let delayTimeout;
|
|
22
22
|
const mode = core.useEditorMode();
|
|
23
|
-
const
|
|
23
|
+
const getImageActiveIndex = React.useCallback(()=>{
|
|
24
24
|
const index = productImages?.findIndex((item)=>item.id === featuredImageGlobal?.id);
|
|
25
|
-
return index;
|
|
25
|
+
return index ?? 0;
|
|
26
26
|
}, [
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
featuredImageGlobal?.id,
|
|
28
|
+
productImages
|
|
29
|
+
]);
|
|
30
|
+
const [imageActiveIndex, setImageActiveIndex] = React.useState(getImageActiveIndex());
|
|
31
|
+
React.useEffect(()=>{
|
|
32
|
+
setImageActiveIndex(getImageActiveIndex());
|
|
33
|
+
}, [
|
|
34
|
+
featuredImageGlobal,
|
|
35
|
+
getImageActiveIndex,
|
|
36
|
+
productImages
|
|
29
37
|
]);
|
|
30
38
|
const imageActive = React.useMemo(()=>{
|
|
31
39
|
if (productImages?.length) return featuredImageGlobal || productImages?.[0];
|
package/dist/esm/product/components/ProductImagesV2/jsx/components/ProductFeaturedImageCarousel.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getAspectRatio } from '../../common/common.js';
|
|
|
6
6
|
import { checkRenderFeaturedCarousel, getDotSettingByLayout } from '../../common/productFeaturedImage.js';
|
|
7
7
|
import { handleMouseMove, handleMouseOut } from '../../common/hoverAction.js';
|
|
8
8
|
import ProductFeaturedImageOnly from './ProductFeaturedImageOnly.js';
|
|
9
|
-
import { memo,
|
|
9
|
+
import { memo, useCallback, useState, useEffect, useMemo, createRef } from 'react';
|
|
10
10
|
import { handleSetSrcForFeatureProductImage } from '../../../../../image/helpers/getSrcSet.js';
|
|
11
11
|
|
|
12
12
|
const ProductFeaturedImageCarousel = ({ productImages, imgRef, onHandleClick, onClickArrow, onHandleLoaded, onHandleUpdateActiveIndex, builderPropUID, builderPropsClass, children, parentUid, ...setting })=>{
|
|
@@ -16,12 +16,20 @@ const ProductFeaturedImageCarousel = ({ productImages, imgRef, onHandleClick, on
|
|
|
16
16
|
const { onListener, ref } = useInteraction();
|
|
17
17
|
let delayTimeout;
|
|
18
18
|
const mode = useEditorMode();
|
|
19
|
-
const
|
|
19
|
+
const getImageActiveIndex = useCallback(()=>{
|
|
20
20
|
const index = productImages?.findIndex((item)=>item.id === featuredImageGlobal?.id);
|
|
21
|
-
return index;
|
|
21
|
+
return index ?? 0;
|
|
22
22
|
}, [
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
featuredImageGlobal?.id,
|
|
24
|
+
productImages
|
|
25
|
+
]);
|
|
26
|
+
const [imageActiveIndex, setImageActiveIndex] = useState(getImageActiveIndex());
|
|
27
|
+
useEffect(()=>{
|
|
28
|
+
setImageActiveIndex(getImageActiveIndex());
|
|
29
|
+
}, [
|
|
30
|
+
featuredImageGlobal,
|
|
31
|
+
getImageActiveIndex,
|
|
32
|
+
productImages
|
|
25
33
|
]);
|
|
26
34
|
const imageActive = useMemo(()=>{
|
|
27
35
|
if (productImages?.length) return featuredImageGlobal || productImages?.[0];
|