oddsgate-ds 1.0.117 → 1.0.119
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,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react'
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
StyledProductsSlider,
|
|
4
4
|
StyledProductsSliderContent,
|
|
@@ -26,6 +26,21 @@ const ProductsSlider = ({
|
|
|
26
26
|
const contentHolder = useRef<HTMLDivElement>();
|
|
27
27
|
const isMobile = useMediaMatch();
|
|
28
28
|
|
|
29
|
+
|
|
30
|
+
//force 26 items
|
|
31
|
+
const newContent = useMemo(() => {
|
|
32
|
+
if (isMobile) {
|
|
33
|
+
return content;
|
|
34
|
+
} else if (content && content.length < 26) {
|
|
35
|
+
let counter = 0;
|
|
36
|
+
for (let i = content.length; i <= 26; i++) {
|
|
37
|
+
content[i] = content[counter];
|
|
38
|
+
counter++;
|
|
39
|
+
}
|
|
40
|
+
return content;
|
|
41
|
+
}
|
|
42
|
+
}, [isMobile, content])
|
|
43
|
+
|
|
29
44
|
useEffect(() => {
|
|
30
45
|
if (!slidesHolder.current) return //bail out;
|
|
31
46
|
|
|
@@ -53,7 +68,7 @@ const ProductsSlider = ({
|
|
|
53
68
|
const setSize = (radius: number) => {
|
|
54
69
|
if (!wrapper.current || !slidesHolder.current || isMobile) return //bail out;
|
|
55
70
|
|
|
56
|
-
const slideSize = 0.
|
|
71
|
+
const slideSize = 0.1;
|
|
57
72
|
|
|
58
73
|
wrapper.current.style.width = 2 * radius + 'px';
|
|
59
74
|
// wrapper.current.style.height = 2 * radius + 'px';
|
|
@@ -170,7 +185,7 @@ const ProductsSlider = ({
|
|
|
170
185
|
<StyledProductsSlider ref={slider as any} className={className} style={style}>
|
|
171
186
|
<StyledProductsSliderWrapper ref={wrapper as any}>
|
|
172
187
|
<StyledProductsSliderSlides ref={slidesHolder as any}>
|
|
173
|
-
{
|
|
188
|
+
{newContent?.map((item, index) => {
|
|
174
189
|
return (
|
|
175
190
|
<StyledProductsSliderSlide key={`ProductCard-${index}`}>
|
|
176
191
|
<ProductCard
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
import { debounce } from './events';
|
|
4
4
|
import { responsiveMediaMax } from '@/styles/variables'
|
|
@@ -7,7 +7,7 @@ import { responsiveMediaMax } from '@/styles/variables'
|
|
|
7
7
|
export default function useMediaMatch(query: string = `(max-width: ${responsiveMediaMax})`) {
|
|
8
8
|
const [matches, setMatches] = useState(false)
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
useMemo(() => {
|
|
11
11
|
const mediaQueryList = window.matchMedia(query)
|
|
12
12
|
|
|
13
13
|
const handleMatchChange = debounce((e) => {
|