react-magic-card 0.1.3 → 0.1.5
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
|
-
|
|
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
|
-
|
|
85
|
-
}
|
|
86
|
-
if (delta < 0) {
|
|
82
|
+
if (delta < (touchStartY || touchStartX))
|
|
87
83
|
shiftLeft();
|
|
88
|
-
|
|
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)(() => {
|
|
@@ -148,7 +144,7 @@ const MagicCircle = ({ images, height, width, radius, controller, start, dynamic
|
|
|
148
144
|
elm.removeEventListener('mouseover', enterControll);
|
|
149
145
|
elm.removeEventListener('mouseout', leaveControll);
|
|
150
146
|
elm.removeEventListener('touchmove', enterControll);
|
|
151
|
-
elm.
|
|
147
|
+
elm.removeEventListener('touchend', leaveControll);
|
|
152
148
|
});
|
|
153
149
|
};
|
|
154
150
|
}, []);
|
|
@@ -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 = (
|
|
66
|
-
const touch =
|
|
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)((
|
|
72
|
-
const touch =
|
|
73
|
-
const delta = !vertical
|
|
74
|
-
|
|
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
|
-
|
|
79
|
-
vertical &&
|
|
80
|
-
(hasPick ? setTouchStartX(delta - 1) : setTouchStartY(delta - 1));
|
|
81
|
-
}
|
|
82
|
-
if (delta < 0) {
|
|
76
|
+
if (delta < (touchStartX || touchStartY))
|
|
83
77
|
shiftLeft();
|
|
84
|
-
|
|
85
|
-
|
|
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)(() => {
|
|
@@ -146,7 +138,7 @@ const MagicStraight = ({ images, height, width, start, controller, wheelDelay, v
|
|
|
146
138
|
elm.removeEventListener('mouseover', enterControll);
|
|
147
139
|
elm.removeEventListener('mouseout', leaveControll);
|
|
148
140
|
elm.removeEventListener('touchmove', enterControll);
|
|
149
|
-
elm.
|
|
141
|
+
elm.removeEventListener('touchend', leaveControll);
|
|
150
142
|
});
|
|
151
143
|
};
|
|
152
144
|
}, []);
|
|
@@ -11,7 +11,6 @@ const PickImage = ({ onClick, classPick, hasPick, hasShift, argRef, argKey, src,
|
|
|
11
11
|
zIndex: zIndex,
|
|
12
12
|
opacity: hasPick ? 1 : 0,
|
|
13
13
|
pointerEvents: hasPick ? 'auto' : 'none',
|
|
14
|
-
touchAction: hasPick ? 'auto' : 'none',
|
|
15
14
|
visibility: hasPick ? 'visible' : 'hidden',
|
|
16
15
|
backdropFilter: `blur(${blur}px)`,
|
|
17
16
|
background: white
|