react-magic-card 0.1.3 → 0.1.4

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.
@@ -76,17 +76,13 @@ const MagicCircle = ({ images, height, width, radius, controller, start, dynamic
76
76
  // Function of the mobile.
77
77
  const handleTouchMove = (0, react_1.useCallback)((event) => {
78
78
  const touch = event.touches[0];
79
- const delta = hasPick
80
- ? touch.clientX - touchStartX
81
- : touch.clientY - touchStartY;
82
- if (delta > 0) {
79
+ const delta = hasPick ? touch.clientX : touch.clientY;
80
+ if (delta > (touchStartY || touchStartX))
83
81
  shiftRight();
84
- setTouchStartX(delta - 1);
85
- }
86
- if (delta < 0) {
82
+ if (delta < (touchStartY || touchStartX))
87
83
  shiftLeft();
88
- setTouchStartY(delta + 1);
89
- }
84
+ setTouchStartX(delta);
85
+ setTouchStartY(delta);
90
86
  }, [shiftLeft, shiftRight, touchStartY]);
91
87
  // Main functional, exit function if ref and hasDelayed does not exist.
92
88
  (0, react_1.useEffect)(() => {
@@ -62,29 +62,21 @@ const MagicStraight = ({ images, height, width, start, controller, wheelDelay, v
62
62
  shiftLeft();
63
63
  }, [shiftLeft, shiftRight]);
64
64
  // Get a start y and x position in touchStart Y and X.
65
- const handleTouchStart = (event) => {
66
- const touch = event.touches[0];
65
+ const handleTouchStart = (e) => {
66
+ const touch = e.touches[0];
67
67
  setTouchStartY(touch.clientY);
68
68
  setTouchStartX(touch.clientX);
69
69
  };
70
70
  // Swipe Function of the mobile.
71
- const handleTouchMove = (0, react_1.useCallback)((event) => {
72
- const touch = event.touches[0];
73
- const delta = !vertical
74
- ? touch.clientX - touchStartX
75
- : touch.clientY - touchStartY;
76
- if (delta > 0) {
71
+ const handleTouchMove = (0, react_1.useCallback)((e) => {
72
+ const touch = e.touches[0];
73
+ const delta = !vertical ? touch.clientX : touch.clientY;
74
+ if (delta > (touchStartX || touchStartY))
77
75
  shiftRight();
78
- !vertical && setTouchStartX(delta - 1);
79
- vertical &&
80
- (hasPick ? setTouchStartX(delta - 1) : setTouchStartY(delta - 1));
81
- }
82
- if (delta < 0) {
76
+ if (delta < (touchStartX || touchStartY))
83
77
  shiftLeft();
84
- !vertical && setTouchStartX(delta + 1);
85
- vertical &&
86
- (hasPick ? setTouchStartX(delta + 1) : setTouchStartY(delta + 1));
87
- }
78
+ setTouchStartX(delta);
79
+ setTouchStartY(delta);
88
80
  }, [hasPick, shiftLeft, shiftRight, touchStartX, touchStartY, vertical]);
89
81
  // Main functional, exit function if ref and hasDelayed does not exist.
90
82
  (0, react_1.useEffect)(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-magic-card",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "image gallery component with framer motion",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",