@astryxdesign/core 0.4.4-canary.eb069fd → 0.4.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.
- package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
- package/dist/BottomSheet/useSheetGestures.js +2 -49
- package/locales/fr-FR.json +0 -928
- package/package.json +3 -3
- package/src/BottomSheet/useSheetGestures.test.ts +0 -45
- package/src/BottomSheet/useSheetGestures.ts +2 -54
- package/locales/af-ZA.json +0 -958
- package/locales/ar-SA.json +0 -998
- package/locales/ca-ES.json +0 -974
- package/locales/cs-CZ.json +0 -990
- package/locales/da-DK.json +0 -966
- package/locales/de-DE.json +0 -966
- package/locales/el-GR.json +0 -990
- package/locales/es-ES.json +0 -978
- package/locales/fi-FI.json +0 -990
- package/locales/he-IL.json +0 -990
- package/locales/hu-HU.json +0 -990
- package/locales/it-IT.json +0 -978
- package/locales/ja-JP.json +0 -998
- package/locales/ko-KR.json +0 -990
- package/locales/nl-NL.json +0 -954
- package/locales/no-NO.json +0 -978
- package/locales/pl-PL.json +0 -982
- package/locales/pt-BR.json +0 -982
- package/locales/pt-PT.json +0 -982
- package/locales/ro-RO.json +0 -982
- package/locales/ru-RU.json +0 -990
- package/locales/sr-SP.json +0 -990
- package/locales/sv-SE.json +0 -986
- package/locales/tr-TR.json +0 -990
- package/locales/uk-UA.json +0 -990
- package/locales/vi-VN.json +0 -986
- package/locales/zh-CN.json +0 -998
- package/locales/zh-TW.json +0 -998
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSheetGestures.d.ts","sourceRoot":"","sources":["../../src/BottomSheet/useSheetGestures.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,UAAU,IAAI,eAAe,EAClC,KAAK,YAAY,IAAI,iBAAiB,EACtC,KAAK,SAAS,EACd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;IAChC,qEAAqE;IACrE,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;;;;OAOG;IACH,wBAAwB,EAAE,MAAM,IAAI,CAAC;IACrC;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AASD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,UAAiB,EACjB,sBAA0B,EAC1B,SAAS,EACT,WAAW,EACX,MAAM,EACN,cAAc,GACf,EAAE,uBAAuB,GAAG,sBAAsB,CA8jClD"}
|
|
@@ -64,18 +64,6 @@ const DISMISS_OVERSHOOT_RATIO = 0.4;
|
|
|
64
64
|
// Within this many px of a detent, the live drag is magnetically eased toward
|
|
65
65
|
// it so it "clicks" into place instead of hovering just off the mark.
|
|
66
66
|
const MAGNET_RANGE = 40;
|
|
67
|
-
// The touch path drives the sheet through the same machinery the pointer path
|
|
68
|
-
// uses, by handing it a pointer-shaped object built from a `Touch`. On iOS
|
|
69
|
-
// Safari that object is indistinguishable from the real thing: WebKit raises
|
|
70
|
-
// PointerEvents for a finger under the SAME numeric id it puts in
|
|
71
|
-
// `Touch.identifier`, so such a drag is keyed to a live pointer and the
|
|
72
|
-
// handlers that guard a mouse drag fire against it. Mark the synthetic object
|
|
73
|
-
// so they can tell the two apart.
|
|
74
|
-
|
|
75
|
-
function isSyntheticTouch(event) {
|
|
76
|
-
return event.syntheticTouch === true;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
67
|
// Rubber-band factor for dragging up past fully-open, capped at OVERSCROLL_MAX
|
|
80
68
|
// (the sheet reserves that much bottom padding for the lift to reveal).
|
|
81
69
|
const OVERSCROLL_RESISTANCE = 0.35;
|
|
@@ -541,16 +529,7 @@ export function useSheetGestures({
|
|
|
541
529
|
}, [detentOffsets, prepareScrollAreaSettle, recordSettledLayoutOffset]);
|
|
542
530
|
const beginDrag = useCallback((event, sheetHeight, startCoord) => {
|
|
543
531
|
const target = event.currentTarget;
|
|
544
|
-
|
|
545
|
-
// Never capture for a touch drag. The id came from `Touch.identifier`,
|
|
546
|
-
// which on iOS names a live pointer: the capture succeeds, WebKit takes
|
|
547
|
-
// it straight back for its own gesture handling, and the
|
|
548
|
-
// `lostpointercapture` a millisecond later cancels the drag that just
|
|
549
|
-
// started. Touch drags need no capture — the listener is on the
|
|
550
|
-
// scroller itself.
|
|
551
|
-
if (!syntheticTouch) {
|
|
552
|
-
target.setPointerCapture?.(event.pointerId);
|
|
553
|
-
}
|
|
532
|
+
target.setPointerCapture?.(event.pointerId);
|
|
554
533
|
// `startCoord` lets a body-overscroll drag anchor at the original
|
|
555
534
|
// pointer-down position (not the promotion point), so the first frame's
|
|
556
535
|
// delta reflects the full pull distance.
|
|
@@ -558,7 +537,6 @@ export function useSheetGestures({
|
|
|
558
537
|
const naturalEndGap = naturalEndGapFor(bodyNodeRef.current);
|
|
559
538
|
const baseLayoutOffset = settledLayoutOffsetRef.current;
|
|
560
539
|
dragStateRef.current = {
|
|
561
|
-
syntheticTouch,
|
|
562
540
|
pointerId: event.pointerId,
|
|
563
541
|
startCoord: start,
|
|
564
542
|
lastCoord: event.clientY,
|
|
@@ -595,12 +573,6 @@ export function useSheetGestures({
|
|
|
595
573
|
cancelDrag(event.currentTarget);
|
|
596
574
|
}, [cancelDrag]);
|
|
597
575
|
const handleLostPointerCapture = useCallback(event => {
|
|
598
|
-
// A touch drag never took capture, so this is WebKit reclaiming its own
|
|
599
|
-
// pointer for the finger doing the dragging — not the drag losing its
|
|
600
|
-
// grip.
|
|
601
|
-
if (dragStateRef.current?.syntheticTouch) {
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
576
|
if (dragStateRef.current?.pointerId === event.pointerId) {
|
|
605
577
|
cancelDrag();
|
|
606
578
|
}
|
|
@@ -610,11 +582,6 @@ export function useSheetGestures({
|
|
|
610
582
|
if (!state || state.pointerId !== event.pointerId) {
|
|
611
583
|
return;
|
|
612
584
|
}
|
|
613
|
-
// Same finger, real pointer event: the touch path already drove this
|
|
614
|
-
// move. Let it own the drag rather than driving it twice.
|
|
615
|
-
if (state.syntheticTouch && !isSyntheticTouch(event)) {
|
|
616
|
-
return;
|
|
617
|
-
}
|
|
618
585
|
const delta = event.clientY - state.startCoord;
|
|
619
586
|
const dt = event.timeStamp - state.lastTime;
|
|
620
587
|
if (dt > 0) {
|
|
@@ -658,20 +625,12 @@ export function useSheetGestures({
|
|
|
658
625
|
if (!state || state.pointerId !== event.pointerId) {
|
|
659
626
|
return;
|
|
660
627
|
}
|
|
661
|
-
// `pointercancel` fires for the finger the moment WebKit claims the
|
|
662
|
-
// gesture; ending a touch drag on it settles the sheet mid-pull. The
|
|
663
|
-
// touchend handler is what finishes a touch drag.
|
|
664
|
-
if (state.syntheticTouch && !isSyntheticTouch(event)) {
|
|
665
|
-
return;
|
|
666
|
-
}
|
|
667
628
|
const target = event.currentTarget;
|
|
668
629
|
const delta = event.clientY - state.startCoord;
|
|
669
630
|
const offset = Math.max(0, state.baseOffset + delta);
|
|
670
631
|
const dir = delta === 0 ? 0 : delta > 0 ? 1 : -1;
|
|
671
632
|
dragStateRef.current = null;
|
|
672
|
-
|
|
673
|
-
target.releasePointerCapture?.(event.pointerId);
|
|
674
|
-
}
|
|
633
|
+
target.releasePointerCapture?.(event.pointerId);
|
|
675
634
|
setIsDragging(false);
|
|
676
635
|
settleFromDrag(offset, state.velocity, state.height || 1, dir, Math.abs(delta), state.baseOffset, state.baseLayoutOffset, state.renderedOffset, state.layoutOffset, state.naturalEndGap);
|
|
677
636
|
}, [settleFromDrag]);
|
|
@@ -718,11 +677,6 @@ export function useSheetGestures({
|
|
|
718
677
|
}, [beginDrag, handlePointerMove, measureHeight]);
|
|
719
678
|
const handleBodyEnd = useCallback(event => {
|
|
720
679
|
armedBodyRef.current = null;
|
|
721
|
-
// The pointerup/pointercancel for a finger already driving a touch drag
|
|
722
|
-
// arrives here carrying that drag's own id; touchend ends those.
|
|
723
|
-
if (dragStateRef.current?.syntheticTouch) {
|
|
724
|
-
return;
|
|
725
|
-
}
|
|
726
680
|
if (dragStateRef.current) {
|
|
727
681
|
endDrag(event);
|
|
728
682
|
}
|
|
@@ -751,7 +705,6 @@ export function useSheetGestures({
|
|
|
751
705
|
});
|
|
752
706
|
const bodyRef = useCallback(node => {
|
|
753
707
|
const asPointer = (touch, target) => ({
|
|
754
|
-
syntheticTouch: true,
|
|
755
708
|
pointerId: touch.identifier,
|
|
756
709
|
clientY: touch.clientY,
|
|
757
710
|
timeStamp: Date.now(),
|