@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.js
CHANGED
|
@@ -137,6 +137,8 @@ function CrisButton({
|
|
|
137
137
|
const pressedRef = (0, import_react.useRef)(false);
|
|
138
138
|
const touchingRef = (0, import_react.useRef)(false);
|
|
139
139
|
const touchStartedHereRef = (0, import_react.useRef)(false);
|
|
140
|
+
const touchStartYRef = (0, import_react.useRef)(0);
|
|
141
|
+
const touchMovedRef = (0, import_react.useRef)(false);
|
|
140
142
|
const feedbackJoin = joinFeedback ?? join;
|
|
141
143
|
const feedback = (0, import_cris_webui_ch5_core.useDigital)(feedbackJoin ?? 0);
|
|
142
144
|
const enabledJoin = (0, import_cris_webui_ch5_core.useDigital)(joinEnable ?? 0);
|
|
@@ -219,30 +221,42 @@ function CrisButton({
|
|
|
219
221
|
dSet(join, false);
|
|
220
222
|
}
|
|
221
223
|
};
|
|
222
|
-
const
|
|
224
|
+
const SCROLL_THRESHOLD = 8;
|
|
225
|
+
const handleTouchStart = (e) => {
|
|
223
226
|
log("handleTouchStart");
|
|
224
227
|
touchStart();
|
|
225
228
|
touchingRef.current = true;
|
|
226
229
|
touchStartedHereRef.current = true;
|
|
227
|
-
|
|
230
|
+
touchMovedRef.current = false;
|
|
231
|
+
touchStartYRef.current = e.touches[0]?.clientY ?? 0;
|
|
232
|
+
};
|
|
233
|
+
const handleTouchMove = (e) => {
|
|
234
|
+
if (touchMovedRef.current) return;
|
|
235
|
+
const dy = Math.abs((e.touches[0]?.clientY ?? 0) - touchStartYRef.current);
|
|
236
|
+
if (dy > SCROLL_THRESHOLD) {
|
|
237
|
+
touchMovedRef.current = true;
|
|
238
|
+
log("touchMove: scroll detected, dy:", dy);
|
|
239
|
+
}
|
|
228
240
|
};
|
|
229
241
|
const handleTouchEnd = () => {
|
|
230
|
-
log("handleTouchEnd", {
|
|
242
|
+
log("handleTouchEnd", { touchStartedHere: touchStartedHereRef.current, moved: touchMovedRef.current });
|
|
231
243
|
touchEnd();
|
|
232
244
|
touchingRef.current = true;
|
|
233
|
-
if (touchStartedHereRef.current) {
|
|
245
|
+
if (touchStartedHereRef.current && !touchMovedRef.current) {
|
|
234
246
|
touchStartedHereRef.current = false;
|
|
247
|
+
handlePress();
|
|
235
248
|
handleRelease();
|
|
236
249
|
} else {
|
|
237
|
-
|
|
250
|
+
touchStartedHereRef.current = false;
|
|
251
|
+
log("SKIPPED: touch moved or did not start here");
|
|
238
252
|
}
|
|
239
253
|
};
|
|
240
254
|
const handleTouchCancel = () => {
|
|
241
|
-
log("handleTouchCancel");
|
|
255
|
+
log("handleTouchCancel (scroll detected)");
|
|
242
256
|
touchEnd();
|
|
243
257
|
touchingRef.current = true;
|
|
244
258
|
touchStartedHereRef.current = false;
|
|
245
|
-
|
|
259
|
+
touchMovedRef.current = false;
|
|
246
260
|
};
|
|
247
261
|
const handleMouseDown = () => {
|
|
248
262
|
if (isTouchActive() || touchingRef.current) return;
|
|
@@ -343,7 +357,7 @@ function CrisButton({
|
|
|
343
357
|
cursor: suppressKeyClicks ? "default" : "pointer",
|
|
344
358
|
position: isFreePositioned ? void 0 : "relative",
|
|
345
359
|
overflow: isFreePositioned ? void 0 : "hidden",
|
|
346
|
-
touchAction: "
|
|
360
|
+
touchAction: "pan-x pan-y",
|
|
347
361
|
userSelect: "none",
|
|
348
362
|
WebkitUserSelect: "none"
|
|
349
363
|
},
|
|
@@ -351,6 +365,7 @@ function CrisButton({
|
|
|
351
365
|
onMouseUp: handleMouseUp,
|
|
352
366
|
onMouseLeave: handleMouseLeave,
|
|
353
367
|
onTouchStart: handleTouchStart,
|
|
368
|
+
onTouchMove: handleTouchMove,
|
|
354
369
|
onTouchEnd: handleTouchEnd,
|
|
355
370
|
onTouchCancel: handleTouchCancel,
|
|
356
371
|
children: [
|