@momo-kits/foundation 0.164.1-beta.3 → 0.164.1-beta.4

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.
@@ -389,6 +389,13 @@ const useSwipeBackHaptic = () => {
389
389
  const { navigator } = useContext<any>(ApplicationContext);
390
390
  const animation = useContext(CardAnimationContext);
391
391
 
392
+ /**
393
+ * the latch has to outlive the effect. `animation` identity changes on every
394
+ * navigator render, so a `hasFired` local re-arms several times per drag and
395
+ * the tick then repeats on every frame past the threshold
396
+ */
397
+ const hasFired = useRef(false);
398
+
392
399
  useEffect(() => {
393
400
  if (Platform.OS !== 'ios' || !animation) {
394
401
  return;
@@ -406,7 +413,6 @@ const useSwipeBackHaptic = () => {
406
413
  * has already been missed
407
414
  */
408
415
  let isSwiping = readAnimatedValue(swiping, 0) === 1;
409
- let hasFired = false;
410
416
 
411
417
  /**
412
418
  * sign, not magnitude: a leftward overdrag reports a negative
@@ -417,7 +423,7 @@ const useSwipeBackHaptic = () => {
417
423
  const swipingListener = swiping.addListener(({ value }) => {
418
424
  isSwiping = value === 1;
419
425
  if (!isSwiping) {
420
- hasFired = false;
426
+ hasFired.current = false;
421
427
  }
422
428
  });
423
429
 
@@ -427,12 +433,12 @@ const useSwipeBackHaptic = () => {
427
433
  }
428
434
 
429
435
  if (translation * direction < SWIPE_BACK_HAPTIC_THRESHOLD) {
430
- hasFired = false;
436
+ hasFired.current = false;
431
437
  return;
432
438
  }
433
439
 
434
- if (!hasFired) {
435
- hasFired = true;
440
+ if (!hasFired.current) {
441
+ hasFired.current = true;
436
442
  navigator?.maxApi?.triggerEventVibration?.('light');
437
443
  }
438
444
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.164.1-beta.3",
3
+ "version": "0.164.1-beta.4",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},