@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.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,22 +184,34 @@ function CrisButton({
182
184
  dSet(join, false);
183
185
  }
184
186
  };
185
- const handleTouchStart = () => {
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;
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
+ }
190
203
  };
191
204
  const handleTouchEnd = () => {
192
- log("handleTouchEnd", { touchStartedHereRef: touchStartedHereRef.current });
205
+ log("handleTouchEnd", { touchStartedHere: touchStartedHereRef.current, moved: touchMovedRef.current });
193
206
  touchEnd();
194
207
  touchingRef.current = true;
195
- if (touchStartedHereRef.current) {
208
+ if (touchStartedHereRef.current && !touchMovedRef.current) {
196
209
  touchStartedHereRef.current = false;
197
210
  handlePress();
198
211
  handleRelease();
199
212
  } else {
200
- log("SKIPPED: touch did not start here");
213
+ touchStartedHereRef.current = false;
214
+ log("SKIPPED: touch moved or did not start here");
201
215
  }
202
216
  };
203
217
  const handleTouchCancel = () => {
@@ -205,6 +219,7 @@ function CrisButton({
205
219
  touchEnd();
206
220
  touchingRef.current = true;
207
221
  touchStartedHereRef.current = false;
222
+ touchMovedRef.current = false;
208
223
  };
209
224
  const handleMouseDown = () => {
210
225
  if (isTouchActive() || touchingRef.current) return;
@@ -305,7 +320,7 @@ function CrisButton({
305
320
  cursor: suppressKeyClicks ? "default" : "pointer",
306
321
  position: isFreePositioned ? void 0 : "relative",
307
322
  overflow: isFreePositioned ? void 0 : "hidden",
308
- touchAction: "pan-y",
323
+ touchAction: "pan-x pan-y",
309
324
  userSelect: "none",
310
325
  WebkitUserSelect: "none"
311
326
  },
@@ -313,6 +328,7 @@ function CrisButton({
313
328
  onMouseUp: handleMouseUp,
314
329
  onMouseLeave: handleMouseLeave,
315
330
  onTouchStart: handleTouchStart,
331
+ onTouchMove: handleTouchMove,
316
332
  onTouchEnd: handleTouchEnd,
317
333
  onTouchCancel: handleTouchCancel,
318
334
  children: [