oddsgate-ds 1.0.116 → 1.0.118
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/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/organisms/ProductsSlider/ProductsSlider.component.tsx +17 -11
- package/src/components/organisms/ProductsSlider/ProductsSlider.theme.ts +3 -2
- package/src/helpers/useMediaMatch.tsx +3 -3
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,14 +26,20 @@ const ProductsSlider = ({
|
|
|
26
26
|
const contentHolder = useRef<HTMLDivElement>();
|
|
27
27
|
const isMobile = useMediaMatch();
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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;
|
|
35
41
|
}
|
|
36
|
-
}
|
|
42
|
+
}, [isMobile, content])
|
|
37
43
|
|
|
38
44
|
useEffect(() => {
|
|
39
45
|
if (!slidesHolder.current) return //bail out;
|
|
@@ -62,11 +68,11 @@ const ProductsSlider = ({
|
|
|
62
68
|
const setSize = (radius: number) => {
|
|
63
69
|
if (!wrapper.current || !slidesHolder.current || isMobile) return //bail out;
|
|
64
70
|
|
|
65
|
-
const slideSize = 0.
|
|
71
|
+
const slideSize = 0.1;
|
|
66
72
|
|
|
67
73
|
wrapper.current.style.width = 2 * radius + 'px';
|
|
68
74
|
// wrapper.current.style.height = 2 * radius + 'px';
|
|
69
|
-
wrapper.current.style.height = '
|
|
75
|
+
wrapper.current.style.height = '680px';
|
|
70
76
|
|
|
71
77
|
let r = 2 * radius * (1 - slideSize);
|
|
72
78
|
slidesHolder.current.style.width = r + 'px'
|
|
@@ -179,7 +185,7 @@ const ProductsSlider = ({
|
|
|
179
185
|
<StyledProductsSlider ref={slider as any} className={className} style={style}>
|
|
180
186
|
<StyledProductsSliderWrapper ref={wrapper as any}>
|
|
181
187
|
<StyledProductsSliderSlides ref={slidesHolder as any}>
|
|
182
|
-
{
|
|
188
|
+
{newContent?.map((item, index) => {
|
|
183
189
|
return (
|
|
184
190
|
<StyledProductsSliderSlide key={`ProductCard-${index}`}>
|
|
185
191
|
<ProductCard
|
|
@@ -21,11 +21,12 @@ export const StyledProductsSliderWrapper = styled.div<IProductsSlider>`
|
|
|
21
21
|
export const StyledProductsSliderSlides = styled.div<IProductsSlider>`
|
|
22
22
|
position: relative;
|
|
23
23
|
display: flex;
|
|
24
|
-
justify-content: center;
|
|
25
|
-
align-items: center;
|
|
26
24
|
flex-flow: row wrap;
|
|
27
25
|
|
|
28
26
|
@media only screen and (min-width: ${responsiveMedia}) {
|
|
27
|
+
justify-content: center;
|
|
28
|
+
align-items: center;
|
|
29
|
+
|
|
29
30
|
transform-origin: center;
|
|
30
31
|
transition: all 0.6s;
|
|
31
32
|
transform: rotate(0deg);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
import { debounce } from './events';
|
|
4
4
|
import { responsiveMediaMax } from '@/styles/variables'
|
|
5
5
|
|
|
6
6
|
// useMediaMatch('(max-width: 600px)')
|
|
7
7
|
export default function useMediaMatch(query: string = `(max-width: ${responsiveMediaMax})`) {
|
|
8
|
-
const [matches, setMatches] = useState(
|
|
8
|
+
const [matches, setMatches] = useState(typeof window !== 'undefined' && window.innerWidth < parseInt(responsiveMediaMax))
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
useMemo(() => {
|
|
11
11
|
const mediaQueryList = window.matchMedia(query)
|
|
12
12
|
|
|
13
13
|
const handleMatchChange = debounce((e) => {
|