@imperosoft/cris-webui-components 1.1.2-beta.11 → 1.1.2-beta.13
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/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -100,6 +100,8 @@ function CrisButton({
|
|
|
100
100
|
const pressedRef = useRef(false);
|
|
101
101
|
const touchingRef = useRef(false);
|
|
102
102
|
const touchStartedHereRef = useRef(false);
|
|
103
|
+
const touchStartYRef = useRef(0);
|
|
104
|
+
const touchMovedRef = useRef(false);
|
|
103
105
|
const feedbackJoin = joinFeedback ?? join;
|
|
104
106
|
const feedback = useDigital(feedbackJoin ?? 0);
|
|
105
107
|
const enabledJoin = useDigital(joinEnable ?? 0);
|
|
@@ -182,30 +184,42 @@ function CrisButton({
|
|
|
182
184
|
dSet(join, false);
|
|
183
185
|
}
|
|
184
186
|
};
|
|
185
|
-
const
|
|
187
|
+
const SCROLL_THRESHOLD = 8;
|
|
188
|
+
const handleTouchStart = (e) => {
|
|
186
189
|
log("handleTouchStart");
|
|
187
190
|
touchStart();
|
|
188
191
|
touchingRef.current = true;
|
|
189
192
|
touchStartedHereRef.current = true;
|
|
190
|
-
|
|
193
|
+
touchMovedRef.current = false;
|
|
194
|
+
touchStartYRef.current = e.touches[0]?.clientY ?? 0;
|
|
195
|
+
};
|
|
196
|
+
const handleTouchMove = (e) => {
|
|
197
|
+
if (touchMovedRef.current) return;
|
|
198
|
+
const dy = Math.abs((e.touches[0]?.clientY ?? 0) - touchStartYRef.current);
|
|
199
|
+
if (dy > SCROLL_THRESHOLD) {
|
|
200
|
+
touchMovedRef.current = true;
|
|
201
|
+
log("touchMove: scroll detected, dy:", dy);
|
|
202
|
+
}
|
|
191
203
|
};
|
|
192
204
|
const handleTouchEnd = () => {
|
|
193
|
-
log("handleTouchEnd", {
|
|
205
|
+
log("handleTouchEnd", { touchStartedHere: touchStartedHereRef.current, moved: touchMovedRef.current });
|
|
194
206
|
touchEnd();
|
|
195
207
|
touchingRef.current = true;
|
|
196
|
-
if (touchStartedHereRef.current) {
|
|
208
|
+
if (touchStartedHereRef.current && !touchMovedRef.current) {
|
|
197
209
|
touchStartedHereRef.current = false;
|
|
210
|
+
handlePress();
|
|
198
211
|
handleRelease();
|
|
199
212
|
} else {
|
|
200
|
-
|
|
213
|
+
touchStartedHereRef.current = false;
|
|
214
|
+
log("SKIPPED: touch moved or did not start here");
|
|
201
215
|
}
|
|
202
216
|
};
|
|
203
217
|
const handleTouchCancel = () => {
|
|
204
|
-
log("handleTouchCancel");
|
|
218
|
+
log("handleTouchCancel (scroll detected)");
|
|
205
219
|
touchEnd();
|
|
206
220
|
touchingRef.current = true;
|
|
207
221
|
touchStartedHereRef.current = false;
|
|
208
|
-
|
|
222
|
+
touchMovedRef.current = false;
|
|
209
223
|
};
|
|
210
224
|
const handleMouseDown = () => {
|
|
211
225
|
if (isTouchActive() || touchingRef.current) return;
|
|
@@ -306,7 +320,7 @@ function CrisButton({
|
|
|
306
320
|
cursor: suppressKeyClicks ? "default" : "pointer",
|
|
307
321
|
position: isFreePositioned ? void 0 : "relative",
|
|
308
322
|
overflow: isFreePositioned ? void 0 : "hidden",
|
|
309
|
-
touchAction: "
|
|
323
|
+
touchAction: "pan-x pan-y",
|
|
310
324
|
userSelect: "none",
|
|
311
325
|
WebkitUserSelect: "none"
|
|
312
326
|
},
|
|
@@ -314,6 +328,7 @@ function CrisButton({
|
|
|
314
328
|
onMouseUp: handleMouseUp,
|
|
315
329
|
onMouseLeave: handleMouseLeave,
|
|
316
330
|
onTouchStart: handleTouchStart,
|
|
331
|
+
onTouchMove: handleTouchMove,
|
|
317
332
|
onTouchEnd: handleTouchEnd,
|
|
318
333
|
onTouchCancel: handleTouchCancel,
|
|
319
334
|
children: [
|