react-magic-card 0.1.9 → 0.1.11

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.
@@ -46,7 +46,7 @@ const MagicCircle = ({ images, height, width, radius, controller, start, dynamic
46
46
  // turn left
47
47
  const shiftLeft = (0, react_1.useCallback)(() => {
48
48
  setSelect(select == 0 ? images.length - 1 : select - 1);
49
- setHasShift(true);
49
+ setHasShift(false);
50
50
  setHasDelayed(false);
51
51
  if (dynamic)
52
52
  return setCount(count + centralAngle);
@@ -54,7 +54,7 @@ const MagicCircle = ({ images, height, width, radius, controller, start, dynamic
54
54
  // turn right
55
55
  const shiftRight = (0, react_1.useCallback)(() => {
56
56
  setSelect(select == images.length - 1 ? 0 : select + 1);
57
- setHasShift(false);
57
+ setHasShift(true);
58
58
  setHasDelayed(false);
59
59
  if (dynamic)
60
60
  return setCount(count - centralAngle);
@@ -77,12 +77,11 @@ const MagicCircle = ({ images, height, width, radius, controller, start, dynamic
77
77
  const handleTouchMove = (0, react_1.useCallback)((event) => {
78
78
  const touch = event.touches[0];
79
79
  const delta = hasPick ? touch.clientX : touch.clientY;
80
- if (delta < (touchStartY || touchStartX))
80
+ if (hasPick ? delta < touchStartX : delta < touchStartY)
81
81
  clockwise ? shiftLeft() : shiftRight();
82
- if (delta > (touchStartY || touchStartX))
82
+ if (hasPick ? delta > touchStartX : delta > touchStartY)
83
83
  clockwise ? shiftRight() : shiftLeft();
84
- setTouchStartX(delta);
85
- setTouchStartY(delta);
84
+ hasPick ? setTouchStartX(delta) : setTouchStartY(delta);
86
85
  }, [clockwise, hasPick, shiftLeft, shiftRight, touchStartX, touchStartY]);
87
86
  // Main functional, exit function if ref and hasDelayed does not exist.
88
87
  (0, react_1.useEffect)(() => {
@@ -75,12 +75,23 @@ const MagicStraight = ({ images, height, width, start, controller, wheelDelay, v
75
75
  : !vertical
76
76
  ? touch.clientX
77
77
  : touch.clientY;
78
- if (delta < (touchStartX || touchStartY))
78
+ if (hasPick
79
+ ? delta < touchStartX
80
+ : !vertical
81
+ ? delta < touchStartX
82
+ : delta < touchStartY)
79
83
  shiftLeft();
80
- if (delta > (touchStartX || touchStartY))
84
+ if (hasPick
85
+ ? delta > touchStartX
86
+ : !vertical
87
+ ? delta > touchStartX
88
+ : delta > touchStartY)
81
89
  shiftRight();
82
- setTouchStartX(delta);
83
- setTouchStartY(delta);
90
+ hasPick
91
+ ? setTouchStartX(delta)
92
+ : !vertical
93
+ ? setTouchStartX(delta)
94
+ : setTouchStartY(delta);
84
95
  }, [hasPick, shiftLeft, shiftRight, touchStartX, touchStartY, vertical]);
85
96
  // Main functional, exit function if ref and hasDelayed does not exist.
86
97
  (0, react_1.useEffect)(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-magic-card",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "image gallery component with framer motion",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",