@broberg/bodymap 0.10.0 → 0.11.0

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/README.md CHANGED
@@ -382,6 +382,23 @@ is invisible on a desktop monitor and obvious on a phone.
382
382
 
383
383
  3D only — the 2D renderer has no canvas and no fullscreen, so it ignores it.
384
384
 
385
+ ### A slow tap is still a tap (0.11.0)
386
+
387
+ Until 0.11.0 a press held longer than **450 ms** was discarded — silently. No
388
+ pick, no clear, no `onFeedback`, no repaint.
389
+
390
+ Distance already separates a tap from a drag: a drag moves. The time ceiling did
391
+ not help with that; what it did was rule that a **slow** press is not a tap. And a
392
+ slow press is exactly what a **careful** tap is — aiming at a small body part on a
393
+ phone, at a mark you are trying to hit again, takes longer than a casual poke.
394
+
395
+ The owner reported it twice, as *"the remove button is gone"* and as *"the sound
396
+ doesn't work"*. Both were the same swallowed tap, and each was explained away
397
+ separately. **A tap that is silently discarded is indistinguishable from a broken
398
+ component.**
399
+
400
+ `isTap(dx, dy)` is exported if you need the same rule.
401
+
385
402
  ### `hint` — turn the help note off, or move it (0.10.0)
386
403
 
387
404
  ```tsx
package/dist/three.cjs CHANGED
@@ -282,6 +282,10 @@ function seamBlend(nearestSq, secondSq) {
282
282
  function seamWeight(seamEnabled, blend) {
283
283
  return seamEnabled ? blend : 0;
284
284
  }
285
+ function isTap(dx, dy, maxDistance = TAP_MAX_DISTANCE) {
286
+ return Math.hypot(dx, dy) <= maxDistance;
287
+ }
288
+ var TAP_MAX_DISTANCE = 6;
285
289
  function ensureNormals(geo) {
286
290
  if (geo.getAttribute("normal")) return false;
287
291
  geo.computeVertexNormals();
@@ -595,12 +599,11 @@ function BodyMap3D(props) {
595
599
  }
596
600
  return best;
597
601
  };
598
- let downX = 0, downY = 0, downT = 0;
602
+ let downX = 0, downY = 0;
599
603
  const canvas = renderer.domElement;
600
604
  const onDown = (e) => {
601
605
  downX = e.clientX;
602
606
  downY = e.clientY;
603
- downT = Date.now();
604
607
  };
605
608
  const onMove = (e) => {
606
609
  if ((e.buttons || 0) !== 0) return;
@@ -612,7 +615,7 @@ function BodyMap3D(props) {
612
615
  renderFrame();
613
616
  };
614
617
  const onUp = (e) => {
615
- if (Math.hypot(e.clientX - downX, e.clientY - downY) > 6 || Date.now() - downT > 450) return;
618
+ if (!isTap(e.clientX - downX, e.clientY - downY)) return;
616
619
  const k = pick(e.clientX, e.clientY);
617
620
  if (!k) return;
618
621
  const outcome = pickRef.current(k);
@@ -853,7 +856,9 @@ function BodyMap3D(props) {
853
856
  }
854
857
 
855
858
  exports.BodyMap3D = BodyMap3D;
859
+ exports.TAP_MAX_DISTANCE = TAP_MAX_DISTANCE;
856
860
  exports.ensureNormals = ensureNormals;
861
+ exports.isTap = isTap;
857
862
  exports.seamBlend = seamBlend;
858
863
  exports.seamWeight = seamWeight;
859
864
  exports.serializeReport = serializeReport;