gatsby-core-theme 30.0.19 → 30.0.21
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [30.0.21](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.20...v30.0.21) (2023-11-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* change import because we have problem on storybook on matrix ([7daaefd](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7daaefd03056d186bd0607d56bf15164e48ae02b))
|
|
7
|
+
|
|
8
|
+
## [30.0.20](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.19...v30.0.20) (2023-11-19)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* add logic for scroll ([6794e5d](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6794e5de5482619f0f9a0328306df906a3b636e1))
|
|
14
|
+
|
|
1
15
|
## [30.0.19](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v30.0.18...v30.0.19) (2023-11-15)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React, { useContext } from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import Button from '~atoms/button/button';
|
|
8
|
-
import imgSize from '
|
|
8
|
+
import imgSize from '../../../constants/spotlight-image-dimensions';
|
|
9
9
|
import LazyImage from '~hooks/lazy-image';
|
|
10
10
|
import keygen from '~helpers/keygen';
|
|
11
11
|
import { imagePrettyUrl, getImageFilename, getAltText, translate } from '~helpers/getters';
|
|
@@ -1,40 +1,64 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// eslint-disable-next-line react/prop-types
|
|
5
|
+
const ScrollX = ({ children, refTag = {}, scroll = false, stopScrolling = () => {} }) => {
|
|
5
6
|
let pos = { top: 0, left: 0, x: 0, y: 0 };
|
|
6
7
|
|
|
8
|
+
const preventDefaultEvents = (e) => {
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
};
|
|
11
|
+
|
|
7
12
|
const mouseMoveHandler = (e) => {
|
|
8
13
|
const dx = e.clientX - pos.x;
|
|
9
14
|
refTag.current.scrollLeft = pos.left - dx;
|
|
10
15
|
};
|
|
11
16
|
|
|
12
|
-
const
|
|
17
|
+
const mouseUp = (e) => {
|
|
13
18
|
refTag.current.style.cursor = 'grab';
|
|
14
19
|
refTag.current.style.removeProperty('user-select');
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
const deltaX = e.clientX - pos.x;
|
|
22
|
+
const deltaY = e.clientY - pos.top;
|
|
23
|
+
const euclidean = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
24
|
+
|
|
25
|
+
if (euclidean < 5) {
|
|
26
|
+
e.target.removeEventListener('click', preventDefaultEvents);
|
|
27
|
+
} else {
|
|
28
|
+
e.target.addEventListener('click', preventDefaultEvents);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
refTag.current.removeEventListener('mousemove', mouseMoveHandler);
|
|
32
|
+
refTag.current.removeEventListener('mouseup', mouseUp);
|
|
33
|
+
refTag.current.removeEventListener('mouseleave', mouseUp);
|
|
34
|
+
stopScrolling();
|
|
18
35
|
};
|
|
19
36
|
|
|
20
|
-
const
|
|
37
|
+
const mouseDown = (e) => {
|
|
21
38
|
refTag.current.style.cursor = 'grabbing';
|
|
22
39
|
refTag.current.style.userSelect = 'none';
|
|
23
40
|
|
|
24
41
|
pos = {
|
|
25
42
|
left: refTag.current.scrollLeft,
|
|
26
43
|
x: e.clientX,
|
|
44
|
+
top: e.clientY,
|
|
27
45
|
};
|
|
28
46
|
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
e.target.addEventListener('dragstart', (e) => {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
refTag.current.addEventListener('mousemove', mouseMoveHandler);
|
|
52
|
+
refTag.current.addEventListener('mouseup', mouseUp);
|
|
53
|
+
refTag.current.addEventListener('mouseleave', mouseUp);
|
|
31
54
|
};
|
|
32
55
|
|
|
33
56
|
useEffect(() => {
|
|
34
57
|
if (scroll) {
|
|
35
58
|
refTag.current.style.cursor = 'grab';
|
|
36
|
-
refTag.current.addEventListener('mousedown',
|
|
59
|
+
refTag.current.addEventListener('mousedown', mouseDown);
|
|
37
60
|
}
|
|
61
|
+
|
|
38
62
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
63
|
}, []);
|
|
40
64
|
|