@imperosoft/cris-webui-components 1.1.2-beta.12 → 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 +21 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -5
- 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,22 +221,34 @@ 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;
|
|
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
|
+
}
|
|
227
240
|
};
|
|
228
241
|
const handleTouchEnd = () => {
|
|
229
|
-
log("handleTouchEnd", {
|
|
242
|
+
log("handleTouchEnd", { touchStartedHere: touchStartedHereRef.current, moved: touchMovedRef.current });
|
|
230
243
|
touchEnd();
|
|
231
244
|
touchingRef.current = true;
|
|
232
|
-
if (touchStartedHereRef.current) {
|
|
245
|
+
if (touchStartedHereRef.current && !touchMovedRef.current) {
|
|
233
246
|
touchStartedHereRef.current = false;
|
|
234
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 = () => {
|
|
@@ -242,6 +256,7 @@ function CrisButton({
|
|
|
242
256
|
touchEnd();
|
|
243
257
|
touchingRef.current = true;
|
|
244
258
|
touchStartedHereRef.current = false;
|
|
259
|
+
touchMovedRef.current = false;
|
|
245
260
|
};
|
|
246
261
|
const handleMouseDown = () => {
|
|
247
262
|
if (isTouchActive() || touchingRef.current) return;
|
|
@@ -342,7 +357,7 @@ function CrisButton({
|
|
|
342
357
|
cursor: suppressKeyClicks ? "default" : "pointer",
|
|
343
358
|
position: isFreePositioned ? void 0 : "relative",
|
|
344
359
|
overflow: isFreePositioned ? void 0 : "hidden",
|
|
345
|
-
touchAction: "pan-y",
|
|
360
|
+
touchAction: "pan-x pan-y",
|
|
346
361
|
userSelect: "none",
|
|
347
362
|
WebkitUserSelect: "none"
|
|
348
363
|
},
|
|
@@ -350,6 +365,7 @@ function CrisButton({
|
|
|
350
365
|
onMouseUp: handleMouseUp,
|
|
351
366
|
onMouseLeave: handleMouseLeave,
|
|
352
367
|
onTouchStart: handleTouchStart,
|
|
368
|
+
onTouchMove: handleTouchMove,
|
|
353
369
|
onTouchEnd: handleTouchEnd,
|
|
354
370
|
onTouchCancel: handleTouchCancel,
|
|
355
371
|
children: [
|