@astryxdesign/core 0.7.5 → 0.7.6-canary.e482998
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/AlertDialog/AlertDialog.d.ts +1 -1
- package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +5 -5
- package/dist/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +12 -3
- package/dist/Badge/Badge.d.ts.map +1 -1
- package/dist/Badge/Badge.js +7 -1
- package/dist/BottomSheet/BottomSheet.js +1 -1
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +2 -1
- package/dist/BottomSheet/useSheetGestures.d.ts +12 -0
- package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
- package/dist/BottomSheet/useSheetGestures.js +30 -3
- package/dist/Button/Button.js +4 -4
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +6 -5
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +12 -4
- package/dist/DateInput/MonthScroller.d.ts.map +1 -1
- package/dist/DateInput/MonthScroller.js +101 -15
- package/dist/DateInput/TouchDateField.d.ts.map +1 -1
- package/dist/DateInput/TouchDateField.js +8 -3
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +1 -1
- package/dist/DateTimeInput/DateTimeInput.d.ts +5 -2
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +23 -12
- package/dist/DateTimeInput/NativeTimeSegment.d.ts.map +1 -1
- package/dist/DateTimeInput/NativeTimeSegment.js +5 -4
- package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
- package/dist/DateTimeInput/TouchDateTimeField.js +4 -3
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +34 -9
- package/dist/Dialog/DialogHeader.d.ts.map +1 -1
- package/dist/Dialog/DialogHeader.js +5 -4
- package/dist/Divider/Divider.d.ts.map +1 -1
- package/dist/Divider/Divider.js +2 -1
- package/dist/Drawer/Drawer.d.ts +1 -0
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +7 -2
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +4 -1
- package/dist/DropdownMenu/MenuBottomSheetActionList.d.ts.map +1 -1
- package/dist/DropdownMenu/MenuBottomSheetActionList.js +6 -5
- package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts +10 -1
- package/dist/DropdownMenu/lazyMenuBottomSheet.d.ts.map +1 -1
- package/dist/DropdownMenu/lazyMenuBottomSheet.js +16 -2
- package/dist/DropdownMenu/renderDropdownItems.d.ts.map +1 -1
- package/dist/DropdownMenu/renderDropdownItems.js +21 -16
- package/dist/EmptyState/EmptyState.d.ts.map +1 -1
- package/dist/EmptyState/EmptyState.js +2 -1
- package/dist/Field/FieldLabel.d.ts +1 -1
- package/dist/Field/FieldLabel.d.ts.map +1 -1
- package/dist/Field/FieldLabel.js +4 -4
- package/dist/Field/InputClearButton.js +3 -3
- package/dist/Field/PanelSearchInput.js +2 -2
- package/dist/FieldStatus/FieldStatus.js +2 -2
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +7 -1
- package/dist/Heading/Heading.js +1 -1
- package/dist/Icon/Icon.js +1 -1
- package/dist/Indicator/CheckIndicator.d.ts.map +1 -1
- package/dist/Indicator/CheckIndicator.js +2 -1
- package/dist/Indicator/CheckboxIndicator.d.ts.map +1 -1
- package/dist/Indicator/CheckboxIndicator.js +3 -1
- package/dist/Indicator/RadioIndicator.d.ts.map +1 -1
- package/dist/Indicator/RadioIndicator.js +3 -1
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +2 -1
- package/dist/Item/ItemSwipeLayer.js +1 -1
- package/dist/Layout/Layout.js +1 -1
- package/dist/Layout/LayoutContent.js +1 -1
- package/dist/Layout/LayoutFooter.js +1 -1
- package/dist/Layout/LayoutHeader.js +1 -1
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +5 -0
- package/dist/Lightbox/LightboxViewport.a11y.browser.spec.js +5 -4
- package/dist/List/List.js +1 -1
- package/dist/List/ListItem.js +3 -3
- package/dist/MobileNav/MobileNav.d.ts.map +1 -1
- package/dist/MobileNav/MobileNav.js +7 -2
- package/dist/MultiSelector/MultiSelector.d.ts +1 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +5 -2
- package/dist/NumberInput/NumberInput.d.ts +3 -1
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +3 -3
- package/dist/NumberInput/numberParser.d.ts +3 -0
- package/dist/NumberInput/numberParser.d.ts.map +1 -1
- package/dist/NumberInput/numberParser.js +7 -44
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +16 -12
- package/dist/Resizable/useResizable.d.ts.map +1 -1
- package/dist/Resizable/useResizable.js +28 -2
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +4 -1
- package/dist/Selector/useSelectorPresentation.d.ts +8 -1
- package/dist/Selector/useSelectorPresentation.d.ts.map +1 -1
- package/dist/Selector/useSelectorPresentation.js +20 -4
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +7 -1
- package/dist/Spinner/Spinner.js +2 -2
- package/dist/Stack/Stack.js +1 -1
- package/dist/Stack/StackItem.js +1 -1
- package/dist/TabList/TabList.d.ts.map +1 -1
- package/dist/TabList/TabList.js +16 -1
- package/dist/Table/plugins/columnResize/useTableColumnResize.d.ts.map +1 -1
- package/dist/Table/plugins/columnResize/useTableColumnResize.js +9 -1
- package/dist/Text/Text.js +1 -1
- package/dist/Text/useTruncation.d.ts.map +1 -1
- package/dist/Text/useTruncation.js +23 -5
- package/dist/TextArea/TextArea.d.ts +1 -1
- package/dist/TextArea/TextArea.d.ts.map +1 -1
- package/dist/TextArea/TextArea.js +13 -2
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +3 -3
- package/dist/TimeInput/TimeInput.d.ts +6 -2
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +21 -14
- package/dist/TimeInput/TouchTimeField.d.ts.map +1 -1
- package/dist/TimeInput/TouchTimeField.js +5 -4
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +2 -2
- package/dist/Timestamp/TimestampHoverCard.js +4 -4
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +60 -20
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +82 -51
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +13 -2
- package/dist/Tokenizer/TokenizerBottomSheet.js +3 -3
- package/dist/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar/Toolbar.js +2 -1
- package/dist/Typeahead/Typeahead.d.ts +1 -1
- package/dist/Typeahead/Typeahead.d.ts.map +1 -1
- package/dist/Typeahead/Typeahead.js +9 -1
- package/dist/astryx.css +15 -1
- package/dist/gestures/PinchGestureRecognizer.d.ts +30 -0
- package/dist/gestures/PinchGestureRecognizer.d.ts.map +1 -0
- package/dist/gestures/PinchGestureRecognizer.js +125 -0
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts +70 -0
- package/dist/gestures/ScreenEdgePanGestureRecognizer.d.ts.map +1 -0
- package/dist/gestures/ScreenEdgePanGestureRecognizer.js +220 -0
- package/dist/gestures/SwipeGestureRecognizer.d.ts +36 -0
- package/dist/gestures/SwipeGestureRecognizer.d.ts.map +1 -0
- package/dist/gestures/SwipeGestureRecognizer.js +145 -0
- package/dist/gestures/VelocityTracker.d.ts +6 -2
- package/dist/gestures/VelocityTracker.d.ts.map +1 -1
- package/dist/gestures/VelocityTracker.js +7 -3
- package/dist/gestures/types.d.ts +11 -7
- package/dist/gestures/types.d.ts.map +1 -1
- package/dist/gestures/types.js +22 -2
- package/dist/hooks/useAdaptivePresentation.d.ts.map +1 -1
- package/dist/hooks/useAdaptivePresentation.js +4 -1
- package/dist/hooks/useMenuHover.d.ts.map +1 -1
- package/dist/hooks/useMenuHover.js +12 -1
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +3 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +3 -0
- package/dist/motion/animator.d.ts +7 -1
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +119 -27
- package/dist/theme/defineTheme.js +1 -1
- package/dist/theme/domainTokens/domainTokenDefaults.d.ts +3 -0
- package/dist/theme/domainTokens/domainTokenDefaults.d.ts.map +1 -0
- package/dist/theme/domainTokens/domainTokenDefaults.js +19 -0
- package/dist/theme/domainTokens/index.d.ts +5 -4
- package/dist/theme/domainTokens/index.d.ts.map +1 -1
- package/dist/theme/domainTokens/index.js +5 -9
- package/dist/utils/focusReturn.d.ts +17 -1
- package/dist/utils/focusReturn.d.ts.map +1 -1
- package/dist/utils/focusReturn.js +11 -4
- package/dist/utils/getNodeText.d.ts +8 -0
- package/dist/utils/getNodeText.d.ts.map +1 -0
- package/dist/utils/getNodeText.js +37 -0
- package/dist/utils/interactionModality.d.ts +11 -2
- package/dist/utils/interactionModality.d.ts.map +1 -1
- package/dist/utils/interactionModality.js +58 -5
- package/dist/utils/plainDate.d.ts +2 -0
- package/dist/utils/plainDate.d.ts.map +1 -1
- package/dist/utils/plainDate.js +46 -3
- package/dist/utils/presentation.d.ts +50 -0
- package/dist/utils/presentation.d.ts.map +1 -0
- package/dist/utils/presentation.js +125 -0
- package/dist/utils/timeFormat.d.ts +47 -0
- package/dist/utils/timeFormat.d.ts.map +1 -0
- package/dist/utils/timeFormat.js +240 -0
- package/dist/utils/touchPresentation.d.ts.map +1 -1
- package/dist/utils/touchPresentation.js +5 -3
- package/dist/utils/touchPresentation.stylex.d.ts +15 -0
- package/dist/utils/touchPresentation.stylex.d.ts.map +1 -0
- package/dist/utils/touchPresentation.stylex.js +33 -0
- package/dist/utils/unicodeDigits.d.ts +20 -0
- package/dist/utils/unicodeDigits.d.ts.map +1 -0
- package/dist/utils/unicodeDigits.js +70 -0
- package/locales/en.json +15 -3
- package/locales/pseudo.json +9 -0
- package/package.json +5 -4
- package/src/AlertDialog/AlertDialog.tsx +6 -5
- package/src/AlertDialog/__tests__/AlertDialog.a11y.chromium.spec.ts +18 -6
- package/src/Avatar/Avatar.spec.md +22 -22
- package/src/Avatar/Avatar.tsx +18 -1
- package/src/Avatar/__tests__/AvatarForcedColors.a11y.chromium.spec.ts +126 -0
- package/src/Badge/Badge.doc.mjs +1 -1
- package/src/Badge/Badge.tsx +19 -2
- package/src/Badge/__tests__/BadgeLargerText.a11y.chromium.spec.ts +260 -0
- package/src/BottomSheet/BottomSheet.test.tsx +46 -0
- package/src/BottomSheet/BottomSheet.tsx +1 -1
- package/src/BottomSheet/BottomSheetPanel.tsx +2 -1
- package/src/BottomSheet/useSheetGestures.test.ts +52 -0
- package/src/BottomSheet/useSheetGestures.ts +37 -6
- package/src/Breadcrumbs/__tests__/Breadcrumbs.a11y.chromium.spec.ts +18 -6
- package/src/Button/Button.tsx +4 -4
- package/src/Calendar/Calendar.spec.md +87 -48
- package/src/Calendar/__tests__/Calendar.a11y.chromium.spec.ts +21 -7
- package/src/Carousel/__tests__/Carousel.a11y.chromium.spec.ts +21 -7
- package/src/CheckboxInput/CheckboxInput.tsx +6 -5
- package/src/Collapsible/Collapsible.spec.md +2 -0
- package/src/Collapsible/CollapsibleGroup.spec.md +57 -29
- package/src/Collapsible/__tests__/Collapsible.a11y.chromium.spec.ts +18 -7
- package/src/Collapsible/__tests__/CollapsibleGroupAccordion.a11y.chromium.spec.ts +18 -6
- package/src/ComplexSelector/ComplexSelector.test.tsx +37 -0
- package/src/ContextMenu/ContextMenu.test.tsx +35 -0
- package/src/DateInput/DateInput.test.tsx +115 -3
- package/src/DateInput/DateInput.tsx +29 -14
- package/src/DateInput/DateInputTouch.test.tsx +76 -0
- package/src/DateInput/MonthScroller.tsx +106 -20
- package/src/DateInput/MonthScrollerSettle.test.tsx +165 -0
- package/src/DateInput/TouchDateField.tsx +14 -3
- package/src/DateInput/__tests__/MonthScrollerSteps.interaction.browser.spec.ts +312 -0
- package/src/DateRangeInput/DateRangeInput.test.tsx +46 -3
- package/src/DateRangeInput/DateRangeInput.tsx +16 -12
- package/src/DateTimeInput/DateTimeInput.doc.mjs +10 -8
- package/src/DateTimeInput/DateTimeInput.spec.md +75 -51
- package/src/DateTimeInput/DateTimeInput.test.tsx +81 -0
- package/src/DateTimeInput/DateTimeInput.tsx +46 -24
- package/src/DateTimeInput/NativeTimeSegment.tsx +4 -6
- package/src/DateTimeInput/TouchDateTimeField.tsx +3 -7
- package/src/Dialog/Dialog.test.tsx +216 -2
- package/src/Dialog/Dialog.tsx +42 -9
- package/src/Dialog/DialogHeader.tsx +5 -4
- package/src/Dialog/__tests__/DialogSecondDocument.a11y.browser.spec.ts +202 -0
- package/src/Divider/Divider.tsx +2 -1
- package/src/Drawer/Drawer.spec.md +111 -80
- package/src/Drawer/Drawer.test.tsx +35 -0
- package/src/Drawer/Drawer.tsx +13 -2
- package/src/Drawer/DrawerHeader.spec.md +181 -0
- package/src/Drawer/__tests__/DrawerNonModalPageScroll.a11y.chromium.spec.ts +267 -0
- package/src/DropdownMenu/DropdownMenu.test.tsx +41 -0
- package/src/DropdownMenu/DropdownMenu.tsx +7 -1
- package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +34 -0
- package/src/DropdownMenu/MenuBottomSheetActionList.tsx +6 -5
- package/src/DropdownMenu/__tests__/Menu.a11y.chromium.spec.ts +19 -7
- package/src/DropdownMenu/__tests__/MenuButton.a11y.chromium.spec.ts +21 -9
- package/src/DropdownMenu/lazyMenuBottomSheet.test.ts +53 -0
- package/src/DropdownMenu/lazyMenuBottomSheet.ts +23 -6
- package/src/DropdownMenu/renderDropdownItems.tsx +24 -19
- package/src/EmptyState/EmptyState.tsx +2 -1
- package/src/Field/FieldLabel.tsx +5 -4
- package/src/Field/InputClearButton.tsx +3 -3
- package/src/Field/PanelSearchInput.tsx +2 -2
- package/src/FieldStatus/FieldStatus.tsx +2 -2
- package/src/FileInput/FileInput.test.tsx +21 -0
- package/src/FileInput/FileInput.tsx +4 -1
- package/src/FormLayout/FormLayout.spec.md +7 -8
- package/src/Heading/Heading.tsx +1 -1
- package/src/Icon/Icon.tsx +1 -1
- package/src/Indicator/CheckIndicator.spec.md +47 -42
- package/src/Indicator/CheckIndicator.tsx +2 -1
- package/src/Indicator/CheckboxIndicator.spec.md +40 -37
- package/src/Indicator/CheckboxIndicator.tsx +3 -1
- package/src/Indicator/Indicator.spec.md +188 -0
- package/src/Indicator/RadioIndicator.tsx +3 -1
- package/src/Item/Item.tsx +2 -1
- package/src/Item/ItemSwipeLayer.tsx +1 -1
- package/src/Layout/Layout.spec.md +127 -131
- package/src/Layout/Layout.tsx +1 -1
- package/src/Layout/LayoutContent.spec.md +205 -0
- package/src/Layout/LayoutContent.tsx +1 -1
- package/src/Layout/LayoutFooter.spec.md +190 -0
- package/src/Layout/LayoutFooter.tsx +1 -1
- package/src/Layout/LayoutHeader.spec.md +193 -0
- package/src/Layout/LayoutHeader.tsx +1 -1
- package/src/Layout/LayoutPanel.spec.md +194 -0
- package/src/Layout/__tests__/Layout.a11y.chromium.spec.ts +18 -6
- package/src/Lightbox/Lightbox.test.tsx +18 -0
- package/src/Lightbox/Lightbox.tsx +5 -0
- package/src/Lightbox/LightboxViewport.a11y.browser.spec.ts +8 -4
- package/src/Link/__tests__/Link.a11y.chromium.spec.ts +18 -8
- package/src/List/List.tsx +1 -1
- package/src/List/ListItem.spec.md +205 -0
- package/src/List/ListItem.tsx +3 -3
- package/src/MobileNav/MobileNav.test.tsx +15 -0
- package/src/MobileNav/MobileNav.tsx +9 -1
- package/src/MobileNav/__tests__/MobileNavHeader.a11y.chromium.spec.ts +89 -0
- package/src/MoreMenu/MoreMenu.test.tsx +11 -0
- package/src/MultiSelector/MultiSelector.spec.md +7 -4
- package/src/MultiSelector/MultiSelector.test.tsx +118 -1
- package/src/MultiSelector/MultiSelector.tsx +6 -2
- package/src/MultiSelector/__tests__/MultiSelector.listbox.a11y.test.tsx +8 -1
- package/src/NavMenu/NavHeadingMenu.spec.md +1 -5
- package/src/NumberInput/NumberInput.doc.mjs +13 -7
- package/src/NumberInput/NumberInput.spec.md +59 -37
- package/src/NumberInput/NumberInput.tsx +13 -3
- package/src/NumberInput/__tests__/NumberInput.coarse-pointer.a11y.chromium.spec.ts +102 -0
- package/src/NumberInput/numberParser.ts +7 -45
- package/src/ProgressBar/ProgressBar.test.tsx +108 -32
- package/src/ProgressBar/ProgressBar.tsx +58 -10
- package/src/ProgressBar/__tests__/ProgressBar.a11y.chromium.spec.ts +21 -9
- package/src/ProgressBar/__tests__/ProgressBarMotion.a11y.chromium.spec.ts +831 -0
- package/src/Resizable/__tests__/ResizeHandle.a11y.chromium.spec.ts +21 -14
- package/src/Resizable/useResizable.test.ts +43 -0
- package/src/Resizable/useResizable.ts +32 -9
- package/src/SegmentedControl/SegmentedControl.test.tsx +84 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +11 -5
- package/src/Selector/Selector.test.tsx +90 -1
- package/src/Selector/__tests__/Selector.combobox.a11y.test.tsx +8 -1
- package/src/Selector/__tests__/Selector.listbox.a11y.test.tsx +8 -1
- package/src/Selector/useSelectorPresentation.ts +31 -3
- package/src/SideNav/SideNav.test.tsx +27 -0
- package/src/SideNav/__tests__/SideNavRailMotion.interaction.browser.spec.ts +176 -51
- package/src/Slider/Slider.test.tsx +12 -0
- package/src/Slider/Slider.tsx +4 -1
- package/src/Slider/__tests__/Slider.a11y.chromium.spec.ts +19 -7
- package/src/Spinner/Spinner.tsx +2 -2
- package/src/Stack/Stack.tsx +1 -1
- package/src/Stack/StackItem.tsx +1 -1
- package/src/TabList/TabList.test.tsx +58 -4
- package/src/TabList/TabList.tsx +16 -1
- package/src/TabList/__tests__/TabPressPointer.interaction.browser.spec.ts +163 -0
- package/src/Table/__tests__/Table.a11y.chromium.spec.ts +18 -6
- package/src/Table/plugins/columnResize/useTableColumnResize.test.tsx +22 -0
- package/src/Table/plugins/columnResize/useTableColumnResize.tsx +8 -4
- package/src/Text/Text.tsx +1 -1
- package/src/Text/useTruncation.test.tsx +128 -1
- package/src/Text/useTruncation.ts +23 -5
- package/src/TextArea/TextArea.spec.md +10 -13
- package/src/TextArea/TextArea.test.tsx +60 -0
- package/src/TextArea/TextArea.tsx +15 -1
- package/src/TextInput/TextInput.test.tsx +21 -0
- package/src/TextInput/TextInput.tsx +3 -1
- package/src/TimeInput/NativeTimeInput.test.tsx +17 -0
- package/src/TimeInput/Presentation.test.tsx +21 -0
- package/src/TimeInput/TimeInput.doc.mjs +8 -8
- package/src/TimeInput/TimeInput.spec.md +45 -48
- package/src/TimeInput/TimeInput.test.tsx +76 -0
- package/src/TimeInput/TimeInput.tsx +36 -18
- package/src/TimeInput/TouchTimeField.tsx +4 -6
- package/src/Timestamp/Timestamp.spec.md +6 -12
- package/src/Timestamp/Timestamp.test.tsx +30 -5
- package/src/Timestamp/Timestamp.tsx +6 -2
- package/src/Timestamp/TimestampHoverCard.tsx +4 -4
- package/src/Toast/Toast.spec.md +14 -20
- package/src/Toast/Toast.tsx +104 -36
- package/src/Toast/ToastViewport.test.tsx +719 -1
- package/src/Toast/ToastViewport.tsx +100 -50
- package/src/Tokenizer/Tokenizer.spec.md +5 -3
- package/src/Tokenizer/Tokenizer.test.tsx +68 -0
- package/src/Tokenizer/Tokenizer.tsx +14 -2
- package/src/Tokenizer/TokenizerBottomSheet.test.tsx +15 -4
- package/src/Tokenizer/TokenizerBottomSheet.tsx +3 -3
- package/src/Toolbar/Toolbar.spec.md +5 -6
- package/src/Toolbar/Toolbar.test.tsx +30 -0
- package/src/Toolbar/Toolbar.tsx +2 -1
- package/src/Toolbar/__tests__/Toolbar.a11y.chromium.spec.ts +18 -6
- package/src/Tooltip/__tests__/Tooltip.a11y.chromium.spec.ts +18 -7
- package/src/TopNav/TopNav.test.tsx +27 -0
- package/src/Typeahead/Typeahead.test.tsx +40 -0
- package/src/Typeahead/Typeahead.tsx +12 -1
- package/src/gestures/PinchGestureRecognizer.ts +144 -0
- package/src/gestures/ScreenEdgePanGestureRecognizer.ts +252 -0
- package/src/gestures/SwipeGestureRecognizer.ts +193 -0
- package/src/gestures/VelocityTracker.ts +10 -3
- package/src/gestures/__tests__/PanGestureRecognizer.test.ts +4 -4
- package/src/gestures/__tests__/PinchGestureRecognizer.test.ts +74 -0
- package/src/gestures/__tests__/ScreenEdgePanGestureRecognizer.test.ts +498 -0
- package/src/gestures/__tests__/SwipeGestureRecognizer.test.ts +108 -0
- package/src/gestures/__tests__/arenaPinchSwipeEdge.test.ts +188 -0
- package/src/gestures/__tests__/harness.ts +21 -2
- package/src/gestures/types.ts +23 -9
- package/src/hooks/useAdaptivePresentation.ts +4 -1
- package/src/hooks/useMenuHover.ts +15 -1
- package/src/i18n/generated-locales/en.generated.ts +4 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +4 -0
- package/src/motion/README.md +11 -1
- package/src/motion/animator.test.ts +151 -3
- package/src/motion/animator.ts +149 -33
- package/src/theme/defineTheme.ts +1 -1
- package/src/theme/derivedVarRegistry.test.ts +4 -0
- package/src/theme/domainTokens/domainTokenDefaults.ts +19 -0
- package/src/theme/domainTokens/index.ts +6 -10
- package/src/utils/focusReturn.ts +17 -6
- package/src/utils/getNodeText.test.ts +24 -0
- package/src/utils/getNodeText.ts +37 -0
- package/src/utils/interactionModality.test.ts +45 -1
- package/src/utils/interactionModality.ts +64 -5
- package/src/utils/plainDate.test.ts +90 -0
- package/src/utils/plainDate.ts +58 -3
- package/src/utils/presentation.test.ts +380 -0
- package/src/utils/presentation.ts +180 -0
- package/src/utils/pressPaintPriority.test.ts +80 -0
- package/src/utils/timeFormat.test.ts +204 -0
- package/src/utils/timeFormat.ts +314 -0
- package/src/utils/touchPresentation.stylex.ts +43 -0
- package/src/utils/touchPresentation.test.ts +140 -1
- package/src/utils/touchPresentation.ts +5 -3
- package/src/utils/unicodeDigits.test.ts +44 -0
- package/src/utils/unicodeDigits.ts +71 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file PinchGestureRecognizer.ts
|
|
5
|
+
* @input Touches from a GestureArena
|
|
6
|
+
* @output Exports PinchGestureRecognizer (UIPinchGestureRecognizer) and its
|
|
7
|
+
* options
|
|
8
|
+
* @position Continuous two-finger recognizer of packages/core/src/gestures
|
|
9
|
+
*
|
|
10
|
+
* Tracks the first two fingers; more are ignored. Begins once the distance
|
|
11
|
+
* between them has changed by `hysteresis` px. As in UIKit, `scale` is then
|
|
12
|
+
* the current distance over the starting distance moved by the hysteresis
|
|
13
|
+
* toward the pinch, so it does not jump (settable to re-base it); `velocity`
|
|
14
|
+
* is scale per second. Lifting either finger ends an
|
|
15
|
+
* active pinch and fails a possible one.
|
|
16
|
+
*
|
|
17
|
+
* A host gives every element WITHOUT a pinch recognizer `pinch-zoom` in its
|
|
18
|
+
* `touch-action`, so the page stays zoomable (WCAG 1.4.4); attaching one
|
|
19
|
+
* takes the two-finger gesture for this element only.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { UIKIT_PINCH } from "../motion/uikit/gestures.js";
|
|
23
|
+
import { centroid, distance } from "./geometry.js";
|
|
24
|
+
import { GestureRecognizer, isActive } from "./GestureRecognizer.js";
|
|
25
|
+
import { VelocityTracker } from "./VelocityTracker.js";
|
|
26
|
+
export class PinchGestureRecognizer extends GestureRecognizer {
|
|
27
|
+
initialSpan = 0;
|
|
28
|
+
scaleValue = 1;
|
|
29
|
+
tracker = new VelocityTracker();
|
|
30
|
+
lastTime = 0;
|
|
31
|
+
constructor(options = {}) {
|
|
32
|
+
super(options);
|
|
33
|
+
this.hysteresis = options.hysteresis ?? UIKIT_PINCH.hysteresis.value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Current span over the span the fingers started at. */
|
|
37
|
+
get scale() {
|
|
38
|
+
return this.scaleValue;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Re-base: from now on the scale reads `value` at the current span. */
|
|
42
|
+
set scale(value) {
|
|
43
|
+
const span = this.span();
|
|
44
|
+
if (span > 0 && value > 0) {
|
|
45
|
+
this.initialSpan = span / value;
|
|
46
|
+
this.scaleValue = value;
|
|
47
|
+
// The velocity continues from the re-based value, without a jump.
|
|
48
|
+
this.tracker.reset();
|
|
49
|
+
this.tracker.add(value, 0, this.lastTime);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Scale per second (UIKit's filter; measured for pans, assumed here). */
|
|
54
|
+
get velocity() {
|
|
55
|
+
return this.tracker.velocity().x;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The midpoint between the two fingers. */
|
|
59
|
+
focalPoint() {
|
|
60
|
+
return centroid(this.touches.values());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Two fingers on this view are this recognizer's, not the browser's zoom. */
|
|
64
|
+
get nativeTouchBehavior() {
|
|
65
|
+
return {
|
|
66
|
+
panX: true,
|
|
67
|
+
panY: true,
|
|
68
|
+
pinchZoom: false,
|
|
69
|
+
doubleTapZoom: false
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
acceptsTouch(touch) {
|
|
73
|
+
return this.numberOfTouches < 2 && super.acceptsTouch(touch);
|
|
74
|
+
}
|
|
75
|
+
touchesBegan(_touches, event) {
|
|
76
|
+
this.lastTime = event.time;
|
|
77
|
+
if (this.numberOfTouches === 2) {
|
|
78
|
+
this.initialSpan = this.span();
|
|
79
|
+
this.scaleValue = 1;
|
|
80
|
+
this.tracker.reset();
|
|
81
|
+
this.tracker.add(1, 0, event.time);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
touchesMoved(_touches, event) {
|
|
85
|
+
if (this.numberOfTouches < 2 || this.initialSpan <= 0) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.lastTime = event.time;
|
|
89
|
+
const span = this.span();
|
|
90
|
+
// Once recognized, a pinch waiting on a recognizer it requires to fail
|
|
91
|
+
// keeps its re-based start: its moves only follow the fingers.
|
|
92
|
+
if (this.state === 'possible' && this.pending == null) {
|
|
93
|
+
if (Math.abs(span - this.initialSpan) >= this.hysteresis) {
|
|
94
|
+
// UIKit measures from the start moved by the hysteresis, and its
|
|
95
|
+
// first velocity spans from the touch-down (scale 1) to here.
|
|
96
|
+
this.initialSpan += Math.sign(span - this.initialSpan) * this.hysteresis;
|
|
97
|
+
this.scaleValue = span / this.initialSpan;
|
|
98
|
+
this.tracker.add(this.scaleValue, 0, event.time);
|
|
99
|
+
this.setState('began');
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.scaleValue = span / this.initialSpan;
|
|
104
|
+
// Every move of the fingers is a sample: a span that holds while they
|
|
105
|
+
// move reads as no change, so the velocity never goes stale.
|
|
106
|
+
this.tracker.add(this.scaleValue, 0, event.time, {
|
|
107
|
+
isMotion: true
|
|
108
|
+
});
|
|
109
|
+
if (isActive(this.state)) {
|
|
110
|
+
this.setState('changed');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
touchesEnded() {
|
|
114
|
+
this.setState(isActive(this.state) ? 'ended' : 'failed');
|
|
115
|
+
}
|
|
116
|
+
reset() {
|
|
117
|
+
this.initialSpan = 0;
|
|
118
|
+
this.scaleValue = 1;
|
|
119
|
+
this.tracker.reset();
|
|
120
|
+
}
|
|
121
|
+
span() {
|
|
122
|
+
const [a, b] = this.trackedTouches;
|
|
123
|
+
return a == null || b == null ? 0 : distance(a, b);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type NativeTouchBehavior } from './GestureRecognizer.js';
|
|
2
|
+
import { PanGestureRecognizer, type PanGestureRecognizerOptions } from './PanGestureRecognizer.js';
|
|
3
|
+
import type { GestureEventContext, GestureTouch } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* An edge by writing direction: under RTL the leading edge is the right one.
|
|
6
|
+
* Top and bottom edges land with their first user.
|
|
7
|
+
*/
|
|
8
|
+
export type ScreenEdge = 'leading' | 'trailing';
|
|
9
|
+
/** A physical horizontal edge of the viewport. */
|
|
10
|
+
type PhysicalEdge = 'left' | 'right';
|
|
11
|
+
/**
|
|
12
|
+
* A screen-edge pan is a finger's: it takes no `allowedPointerTypes`
|
|
13
|
+
* (`spec:AST-094` FR43).
|
|
14
|
+
*/
|
|
15
|
+
export interface ScreenEdgePanGestureRecognizerOptions extends Omit<PanGestureRecognizerOptions, 'direction' | 'allowedPointerTypes'> {
|
|
16
|
+
/** The edges a touch may start from. @default ['leading'] */
|
|
17
|
+
edges?: ReadonlyArray<ScreenEdge>;
|
|
18
|
+
/** Width of the band at each edge, px. */
|
|
19
|
+
edgeRegion?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare class ScreenEdgePanGestureRecognizer extends PanGestureRecognizer {
|
|
22
|
+
edges: ReadonlyArray<ScreenEdge>;
|
|
23
|
+
edgeRegion: number;
|
|
24
|
+
/** The physical edge the current gesture started from. */
|
|
25
|
+
activeEdge: PhysicalEdge | null;
|
|
26
|
+
/**
|
|
27
|
+
* @internal Set by the host while attached: called when the edge-zone
|
|
28
|
+
* answer changes, so the element's `touch-action` follows it
|
|
29
|
+
* (spec:AST-094 FR19, DEC-22).
|
|
30
|
+
*/
|
|
31
|
+
onTouchBehaviorChange: (() => void) | null;
|
|
32
|
+
/** The hysteresis where the pan takes its axis (UIKit's 15 px). */
|
|
33
|
+
private readonly edgeHysteresis;
|
|
34
|
+
/** What the pan measured of its view (see EdgeLayout), until a layout change. */
|
|
35
|
+
private layout;
|
|
36
|
+
constructor(options?: ScreenEdgePanGestureRecognizerOptions);
|
|
37
|
+
/**
|
|
38
|
+
* The pan takes the horizontal axis only in its edge zone, a view within
|
|
39
|
+
* the band of an edge it watches; elsewhere it leaves the browser every
|
|
40
|
+
* touch behavior, so the author's scrolling is untouched (spec:AST-094
|
|
41
|
+
* FR18), never claiming across a whole wider element.
|
|
42
|
+
*/
|
|
43
|
+
get nativeTouchBehavior(): NativeTouchBehavior;
|
|
44
|
+
/**
|
|
45
|
+
* @internal Whether the edge zone depends on the viewport's width: the pan
|
|
46
|
+
* watches the right side, whose band moves with the viewport, so the host
|
|
47
|
+
* reports a viewport resize to it as well as its own box's (FR19, FR24).
|
|
48
|
+
*/
|
|
49
|
+
get watchesViewport(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* @internal The view's box may have changed (a resize): its edges' sides
|
|
52
|
+
* and the edge zone are measured again, and a changed answer calls
|
|
53
|
+
* onTouchBehaviorChange.
|
|
54
|
+
*/
|
|
55
|
+
layoutChanged(): void;
|
|
56
|
+
protected touchesBegan(touches: ReadonlyArray<GestureTouch>, event: GestureEventContext): void;
|
|
57
|
+
/**
|
|
58
|
+
* The physical sides the pan's edges resolve to under the view's writing
|
|
59
|
+
* direction, and the sides whose band the view lies within, measured
|
|
60
|
+
* together once until a layout change: the view starts at that side and
|
|
61
|
+
* reaches no farther than `edgeRegion` from it, within layout's rounding
|
|
62
|
+
* (a strip authored at the 40.2 px region lays out at 40.203 px, on
|
|
63
|
+
* 1/64 px). A view that cannot be measured lies within none.
|
|
64
|
+
*/
|
|
65
|
+
private measured;
|
|
66
|
+
protected reset(): void;
|
|
67
|
+
private edgeAt;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=ScreenEdgePanGestureRecognizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScreenEdgePanGestureRecognizer.d.ts","sourceRoot":"","sources":["../../src/gestures/ScreenEdgePanGestureRecognizer.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAmB,KAAK,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EACL,oBAAoB,EACpB,KAAK,2BAA2B,EACjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAC,mBAAmB,EAAE,YAAY,EAAC,MAAM,SAAS,CAAC;AAS/D;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AAEhD,kDAAkD;AAClD,KAAK,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAarC;;;GAGG;AACH,MAAM,WAAW,qCAAsC,SAAQ,IAAI,CACjE,2BAA2B,EAC3B,WAAW,GAAG,qBAAqB,CACpC;IACC,6DAA6D;IAC7D,KAAK,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAClC,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,8BAA+B,SAAQ,oBAAoB;IACtE,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,UAAU,EAAE,YAAY,GAAG,IAAI,CAAQ;IACvC;;;;OAIG;IACH,qBAAqB,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAQ;IAClD,mEAAmE;IACnE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,iFAAiF;IACjF,OAAO,CAAC,MAAM,CAA2B;gBAE7B,OAAO,GAAE,qCAA0C;IAe/D;;;;;OAKG;IACH,IAAa,mBAAmB,IAAI,mBAAmB,CAWtD;IAED;;;;OAIG;IACH,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED;;;;OAIG;IACH,aAAa,IAAI,IAAI;cAcF,YAAY,CAC7B,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,EACpC,KAAK,EAAE,mBAAmB,GACzB,IAAI;IAiCP;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ;cAyBG,KAAK,IAAI,IAAI;IAKhC,OAAO,CAAC,MAAM;CAaf"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file ScreenEdgePanGestureRecognizer.ts
|
|
5
|
+
* @input Touches from a GestureArena; the viewport size and writing
|
|
6
|
+
* direction from its environment
|
|
7
|
+
* @output Exports ScreenEdgePanGestureRecognizer
|
|
8
|
+
* (UIScreenEdgePanGestureRecognizer), its options and edge type
|
|
9
|
+
* @position Continuous recognizer of packages/core/src/gestures, a pan that
|
|
10
|
+
* only starts from a band at the edge of the viewport
|
|
11
|
+
*
|
|
12
|
+
* A touch that lands outside every requested band fails at once, so a
|
|
13
|
+
* recognizer that requires this one to fail is not held up by a touch in the
|
|
14
|
+
* middle of the screen. Inside a band, the pan begins on movement away from
|
|
15
|
+
* that edge. `leading` and `trailing` resolve against the view's writing
|
|
16
|
+
* direction: under RTL the leading edge is the right one, as the
|
|
17
|
+
* interactive pop gesture's is.
|
|
18
|
+
*
|
|
19
|
+
* Attach it to the edge zone: an element that lies within the band at its
|
|
20
|
+
* edge. There the pan takes the horizontal axis from the browser, which has
|
|
21
|
+
* nothing to scroll in so thin a band, so a touch in the band decides at
|
|
22
|
+
* UIKit's 15 px screen-edge hysteresis. On any other view, whose
|
|
23
|
+
* `touch-action` cannot claim per touch, it leaves the browser every touch
|
|
24
|
+
* behavior, so the author's scrolling there is untouched, and a touch in the
|
|
25
|
+
* band decides at FR19's 10 px like every other claim (spec:AST-094 FR18,
|
|
26
|
+
* DEC-22). The edges' physical sides and the edge zone are measured once,
|
|
27
|
+
* together, and serve both the element's `touch-action` and the touch-down
|
|
28
|
+
* decision; the host reports a layout change (layoutChanged), and a changed
|
|
29
|
+
* answer is announced (onTouchBehaviorChange) so `touch-action` follows it
|
|
30
|
+
* (FR19). The writing direction is read again at each touch-down: a view
|
|
31
|
+
* switched to RTL in place, with no resize, is measured again there and the
|
|
32
|
+
* change announced, so a `leading` back swipe follows the new leading edge
|
|
33
|
+
* (`design:bidirectionality` DR13). That touch landed under the touch-action
|
|
34
|
+
* from before, so it decides at FR19's 10 px unless that one claimed the
|
|
35
|
+
* axis.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
import { UIKIT_PAN, UIKIT_SCREEN_EDGE_PAN } from "../motion/uikit/gestures.js";
|
|
39
|
+
import { ALL_NATIVE_TOUCH } from "./GestureRecognizer.js";
|
|
40
|
+
import { PanGestureRecognizer } from "./PanGestureRecognizer.js";
|
|
41
|
+
/**
|
|
42
|
+
* How far past `edgeRegion` a view still counts as the edge zone, px: layout
|
|
43
|
+
* snaps sizes to 1/64 px, so a strip authored at the region measures a hair
|
|
44
|
+
* wider; half a pixel takes that and nothing a pixel wider.
|
|
45
|
+
*/
|
|
46
|
+
const EDGE_ZONE_TOLERANCE = 0.5;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* An edge by writing direction: under RTL the leading edge is the right one.
|
|
50
|
+
* Top and bottom edges land with their first user.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/** A physical horizontal edge of the viewport. */
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* What the pan measures of its view, once until a layout change: the
|
|
57
|
+
* writing direction it read, the physical sides its edges resolve to under
|
|
58
|
+
* that direction, and the sides whose band the view lies within.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A screen-edge pan is a finger's: it takes no `allowedPointerTypes`
|
|
63
|
+
* (`spec:AST-094` FR43).
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
export class ScreenEdgePanGestureRecognizer extends PanGestureRecognizer {
|
|
67
|
+
/** The physical edge the current gesture started from. */
|
|
68
|
+
activeEdge = null;
|
|
69
|
+
/**
|
|
70
|
+
* @internal Set by the host while attached: called when the edge-zone
|
|
71
|
+
* answer changes, so the element's `touch-action` follows it
|
|
72
|
+
* (spec:AST-094 FR19, DEC-22).
|
|
73
|
+
*/
|
|
74
|
+
onTouchBehaviorChange = null;
|
|
75
|
+
/** The hysteresis where the pan takes its axis (UIKit's 15 px). */
|
|
76
|
+
|
|
77
|
+
/** What the pan measured of its view (see EdgeLayout), until a layout change. */
|
|
78
|
+
layout = null;
|
|
79
|
+
constructor(options = {}) {
|
|
80
|
+
super({
|
|
81
|
+
maximumNumberOfTouches: 1,
|
|
82
|
+
hysteresis: UIKIT_SCREEN_EDGE_PAN.hysteresis.value,
|
|
83
|
+
...options,
|
|
84
|
+
// A finger's only: under a mouse, a trackpad or a pen the screen-edge
|
|
85
|
+
// pan stays off (`spec:AST-094` FR43), whatever a caller passes.
|
|
86
|
+
allowedPointerTypes: ['touch']
|
|
87
|
+
});
|
|
88
|
+
this.edges = options.edges ?? ['leading'];
|
|
89
|
+
this.edgeRegion = options.edgeRegion ?? UIKIT_SCREEN_EDGE_PAN.edgeRegion.value;
|
|
90
|
+
this.edgeHysteresis = this.hysteresis;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The pan takes the horizontal axis only in its edge zone, a view within
|
|
95
|
+
* the band of an edge it watches; elsewhere it leaves the browser every
|
|
96
|
+
* touch behavior, so the author's scrolling is untouched (spec:AST-094
|
|
97
|
+
* FR18), never claiming across a whole wider element.
|
|
98
|
+
*/
|
|
99
|
+
get nativeTouchBehavior() {
|
|
100
|
+
const {
|
|
101
|
+
watched,
|
|
102
|
+
zone
|
|
103
|
+
} = this.measured();
|
|
104
|
+
if (!watched.some(edge => zone.has(edge))) {
|
|
105
|
+
return ALL_NATIVE_TOUCH;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
panX: false,
|
|
109
|
+
panY: true,
|
|
110
|
+
pinchZoom: true,
|
|
111
|
+
doubleTapZoom: false
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @internal Whether the edge zone depends on the viewport's width: the pan
|
|
117
|
+
* watches the right side, whose band moves with the viewport, so the host
|
|
118
|
+
* reports a viewport resize to it as well as its own box's (FR19, FR24).
|
|
119
|
+
*/
|
|
120
|
+
get watchesViewport() {
|
|
121
|
+
return this.measured().watched.includes('right');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @internal The view's box may have changed (a resize): its edges' sides
|
|
126
|
+
* and the edge zone are measured again, and a changed answer calls
|
|
127
|
+
* onTouchBehaviorChange.
|
|
128
|
+
*/
|
|
129
|
+
layoutChanged() {
|
|
130
|
+
const before = this.layout;
|
|
131
|
+
this.layout = null;
|
|
132
|
+
const after = this.measured();
|
|
133
|
+
if (before == null || before.watched.join() !== after.watched.join() || before.zone.size !== after.zone.size || [...after.zone].some(edge => !before.zone.has(edge))) {
|
|
134
|
+
this.onTouchBehaviorChange?.();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
touchesBegan(touches, event) {
|
|
138
|
+
if (this.numberOfTouches === touches.length) {
|
|
139
|
+
// The touch-action the browser applies to this touch was derived from
|
|
140
|
+
// the layout in force as it landed: whether that claimed the axis.
|
|
141
|
+
const inForce = this.measured();
|
|
142
|
+
const claimedAxis = inForce.watched.some(side => inForce.zone.has(side));
|
|
143
|
+
// A direction switched in place (no resize) moves the leading edge:
|
|
144
|
+
// measure again, and announce it so touch-action follows for the next
|
|
145
|
+
// touch (DR13).
|
|
146
|
+
if (inForce.isRtl !== this.environment.isRtl(this.view)) {
|
|
147
|
+
this.layoutChanged();
|
|
148
|
+
}
|
|
149
|
+
const edge = this.edgeAt(touches[0]);
|
|
150
|
+
if (edge == null) {
|
|
151
|
+
this.setState('failed');
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.activeEdge = edge;
|
|
155
|
+
// On an element within the band, which takes the axis across the edge,
|
|
156
|
+
// a touch decides at UIKit's 15 px; on any other, which leaves the
|
|
157
|
+
// browser that axis, at FR19's 10 px, before the browser commits to a
|
|
158
|
+
// scroll (spec:AST-094 FR18, DEC-22). The answer is the one this
|
|
159
|
+
// touch's touch-action was derived from: a touch that measured again
|
|
160
|
+
// decides at 10 px unless the layout in force claimed the axis.
|
|
161
|
+
const offZone = !claimedAxis || !this.measured().zone.has(edge);
|
|
162
|
+
this.hysteresis = offZone ? Math.min(this.edgeHysteresis, UIKIT_PAN.hysteresis.value) : this.edgeHysteresis;
|
|
163
|
+
this.direction = edge === 'left' ? 'right' : 'left';
|
|
164
|
+
}
|
|
165
|
+
super.touchesBegan(touches, event);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The physical sides the pan's edges resolve to under the view's writing
|
|
170
|
+
* direction, and the sides whose band the view lies within, measured
|
|
171
|
+
* together once until a layout change: the view starts at that side and
|
|
172
|
+
* reaches no farther than `edgeRegion` from it, within layout's rounding
|
|
173
|
+
* (a strip authored at the 40.2 px region lays out at 40.203 px, on
|
|
174
|
+
* 1/64 px). A view that cannot be measured lies within none.
|
|
175
|
+
*/
|
|
176
|
+
measured() {
|
|
177
|
+
if (this.layout != null) {
|
|
178
|
+
return this.layout;
|
|
179
|
+
}
|
|
180
|
+
const isRtl = this.environment.isRtl(this.view);
|
|
181
|
+
const watched = this.edges.map(edge => edge === 'leading' !== isRtl ? 'left' : 'right');
|
|
182
|
+
const zone = new Set();
|
|
183
|
+
const rect = this.environment.viewRect?.(this.view);
|
|
184
|
+
if (rect != null && rect.width > 0) {
|
|
185
|
+
const {
|
|
186
|
+
width
|
|
187
|
+
} = this.environment.viewportSize();
|
|
188
|
+
const right = rect.left + rect.width;
|
|
189
|
+
const band = this.edgeRegion + EDGE_ZONE_TOLERANCE;
|
|
190
|
+
if (rect.left >= -EDGE_ZONE_TOLERANCE && right <= band) {
|
|
191
|
+
zone.add('left');
|
|
192
|
+
}
|
|
193
|
+
if (rect.left >= width - band && right <= width + EDGE_ZONE_TOLERANCE) {
|
|
194
|
+
zone.add('right');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
this.layout = {
|
|
198
|
+
isRtl,
|
|
199
|
+
watched,
|
|
200
|
+
zone
|
|
201
|
+
};
|
|
202
|
+
return this.layout;
|
|
203
|
+
}
|
|
204
|
+
reset() {
|
|
205
|
+
super.reset();
|
|
206
|
+
this.activeEdge = null;
|
|
207
|
+
}
|
|
208
|
+
edgeAt(touch) {
|
|
209
|
+
const {
|
|
210
|
+
width
|
|
211
|
+
} = this.environment.viewportSize();
|
|
212
|
+
for (const physical of this.measured().watched) {
|
|
213
|
+
const inBand = physical === 'left' ? touch.startX <= this.edgeRegion : touch.startX >= width - this.edgeRegion;
|
|
214
|
+
if (inBand) {
|
|
215
|
+
return physical;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GestureRecognizer, type GestureRecognizerOptions, type NativeTouchBehavior } from './GestureRecognizer.js';
|
|
2
|
+
import type { GestureEventContext, GestureTouch } from './types.js';
|
|
3
|
+
export type SwipeDirection = 'left' | 'right' | 'up' | 'down';
|
|
4
|
+
export interface SwipeGestureRecognizerOptions extends GestureRecognizerOptions<SwipeGestureRecognizer> {
|
|
5
|
+
/** @default ['right'] */
|
|
6
|
+
direction?: SwipeDirection | ReadonlyArray<SwipeDirection>;
|
|
7
|
+
/** @default 1 */
|
|
8
|
+
numberOfTouchesRequired?: number;
|
|
9
|
+
minimumDistance?: number;
|
|
10
|
+
maximumDuration?: number;
|
|
11
|
+
maximumSecondaryMovement?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class SwipeGestureRecognizer extends GestureRecognizer {
|
|
14
|
+
directions: ReadonlyArray<SwipeDirection>;
|
|
15
|
+
numberOfTouchesRequired: number;
|
|
16
|
+
minimumDistance: number;
|
|
17
|
+
maximumDuration: number;
|
|
18
|
+
maximumSecondaryMovement: number;
|
|
19
|
+
/** The direction of the recognized swipe. */
|
|
20
|
+
recognizedDirection: SwipeDirection | null;
|
|
21
|
+
private origin;
|
|
22
|
+
/** Directions this touch's path has ruled out. */
|
|
23
|
+
private readonly ruledOut;
|
|
24
|
+
/** The centroid at the previous move. */
|
|
25
|
+
private last;
|
|
26
|
+
constructor(options?: SwipeGestureRecognizerOptions);
|
|
27
|
+
get isDiscrete(): boolean;
|
|
28
|
+
get nativeTouchBehavior(): NativeTouchBehavior;
|
|
29
|
+
protected touchesBegan(touches: ReadonlyArray<GestureTouch>, event: GestureEventContext): void;
|
|
30
|
+
protected touchesMoved(): void;
|
|
31
|
+
/** Travel along and across `direction` from the origin to `point`. */
|
|
32
|
+
private project;
|
|
33
|
+
protected touchesEnded(): void;
|
|
34
|
+
protected reset(): void;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=SwipeGestureRecognizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwipeGestureRecognizer.d.ts","sourceRoot":"","sources":["../../src/gestures/SwipeGestureRecognizer.ts"],"names":[],"mappings":"AAqBA,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,mBAAmB,EAAE,YAAY,EAAQ,MAAM,SAAS,CAAC;AAEtE,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;AAE9D,MAAM,WAAW,6BAA8B,SAAQ,wBAAwB,CAAC,sBAAsB,CAAC;IACrG,yBAAyB;IACzB,SAAS,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;IAC3D,iBAAiB;IACjB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAID,qBAAa,sBAAuB,SAAQ,iBAAiB;IAC3D,UAAU,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC1C,uBAAuB,EAAE,MAAM,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,EAAE,MAAM,CAAC;IACjC,6CAA6C;IAC7C,mBAAmB,EAAE,cAAc,GAAG,IAAI,CAAQ;IAElD,OAAO,CAAC,MAAM,CAAuB;IACrC,kDAAkD;IAClD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IACtD,yCAAyC;IACzC,OAAO,CAAC,IAAI,CAAsB;gBAEtB,OAAO,GAAE,6BAAkC;IAavD,IAAa,UAAU,IAAI,OAAO,CAEjC;IAED,IAAa,mBAAmB,IAAI,mBAAmB,CAatD;cAEkB,YAAY,CAC7B,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,EACpC,KAAK,EAAE,mBAAmB,GACzB,IAAI;cAmBY,YAAY,IAAI,IAAI;IAyCvC,sEAAsE;IACtE,OAAO,CAAC,OAAO;cAYI,YAAY,IAAI,IAAI;cAOpB,KAAK,IAAI,IAAI;CAMjC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file SwipeGestureRecognizer.ts
|
|
5
|
+
* @input Touches from a GestureArena
|
|
6
|
+
* @output Exports SwipeGestureRecognizer (UISwipeGestureRecognizer), its
|
|
7
|
+
* options and direction type
|
|
8
|
+
* @position Discrete recognizer of packages/core/src/gestures
|
|
9
|
+
*
|
|
10
|
+
* Recognized WHILE the fingers move, as UIKit's is: as soon as the centroid
|
|
11
|
+
* has travelled `minimumDistance` along an allowed direction, within
|
|
12
|
+
* `maximumDuration` of touch-down, with off-axis travel no more than
|
|
13
|
+
* `maximumSecondaryMovement` px across it. Off-axis travel past that
|
|
14
|
+
* allowance, or the distance travelled the wrong way, rules a direction out;
|
|
15
|
+
* the swipe fails once every allowed direction is ruled out, as it does for
|
|
16
|
+
* too many fingers, the duration running out, and a lift before it was
|
|
17
|
+
* recognized.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { UIKIT_SWIPE } from "../motion/uikit/gestures.js";
|
|
21
|
+
import { centroid } from "./geometry.js";
|
|
22
|
+
import { GestureRecognizer } from "./GestureRecognizer.js";
|
|
23
|
+
const SWIPE = UIKIT_SWIPE;
|
|
24
|
+
export class SwipeGestureRecognizer extends GestureRecognizer {
|
|
25
|
+
/** The direction of the recognized swipe. */
|
|
26
|
+
recognizedDirection = null;
|
|
27
|
+
origin = {
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0
|
|
30
|
+
};
|
|
31
|
+
/** Directions this touch's path has ruled out. */
|
|
32
|
+
ruledOut = new Set();
|
|
33
|
+
/** The centroid at the previous move. */
|
|
34
|
+
last = null;
|
|
35
|
+
constructor(options = {}) {
|
|
36
|
+
super(options);
|
|
37
|
+
const direction = options.direction ?? ['right'];
|
|
38
|
+
this.directions = typeof direction === 'string' ? [direction] : direction;
|
|
39
|
+
this.numberOfTouchesRequired = options.numberOfTouchesRequired ?? 1;
|
|
40
|
+
this.minimumDistance = options.minimumDistance ?? SWIPE.minimumDistance.value;
|
|
41
|
+
this.maximumDuration = options.maximumDuration ?? SWIPE.maximumDuration.value;
|
|
42
|
+
this.maximumSecondaryMovement = options.maximumSecondaryMovement ?? SWIPE.maximumSecondaryMovement.value;
|
|
43
|
+
}
|
|
44
|
+
get isDiscrete() {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
get nativeTouchBehavior() {
|
|
48
|
+
const horizontal = this.directions.some(direction => direction === 'left' || direction === 'right');
|
|
49
|
+
const vertical = this.directions.some(direction => direction === 'up' || direction === 'down');
|
|
50
|
+
return {
|
|
51
|
+
panX: !horizontal,
|
|
52
|
+
panY: !vertical,
|
|
53
|
+
pinchZoom: true,
|
|
54
|
+
doubleTapZoom: false
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
touchesBegan(touches, event) {
|
|
58
|
+
if (this.numberOfTouches > this.numberOfTouchesRequired) {
|
|
59
|
+
this.setState('failed');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (this.numberOfTouches === touches.length) {
|
|
63
|
+
this.setTimer(event.time + this.maximumDuration, () => {
|
|
64
|
+
// A swipe already recognized, waiting on a recognizer it requires to
|
|
65
|
+
// fail, holds its recognition (spec:AST-094 FR15).
|
|
66
|
+
if (this.pending == null) {
|
|
67
|
+
this.setState('failed');
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// Measure from where every required finger is down.
|
|
72
|
+
this.origin = centroid(this.touches.values());
|
|
73
|
+
this.last = null;
|
|
74
|
+
}
|
|
75
|
+
touchesMoved() {
|
|
76
|
+
if (this.pending != null || this.numberOfTouches !== this.numberOfTouchesRequired) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const current = centroid(this.touches.values());
|
|
80
|
+
const from = this.last ?? this.origin;
|
|
81
|
+
this.last = current;
|
|
82
|
+
for (const direction of this.directions) {
|
|
83
|
+
if (this.ruledOut.has(direction)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
// Along and across this direction at the start and the end of the
|
|
87
|
+
// move. The path between two events is read as a straight segment, so
|
|
88
|
+
// the verdict does not depend on how far apart the events were.
|
|
89
|
+
const [along0, across0] = this.project(direction, from);
|
|
90
|
+
const [along1, across1] = this.project(direction, current);
|
|
91
|
+
const reaches = segmentCrossing(along0, along1, this.minimumDistance);
|
|
92
|
+
const strays = Math.max(segmentCrossing(across0, across1, this.maximumSecondaryMovement), segmentCrossing(-across0, -across1, this.maximumSecondaryMovement));
|
|
93
|
+
const strayAt = strays < 0 ? Infinity : strays;
|
|
94
|
+
if (reaches >= 0 && reaches <= strayAt) {
|
|
95
|
+
this.recognizedDirection = direction;
|
|
96
|
+
this.setState('ended');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
// Off-axis travel past the allowance, or the distance the wrong way,
|
|
100
|
+
// rules a direction out for good.
|
|
101
|
+
if (strays >= 0 || along1 <= -this.minimumDistance) {
|
|
102
|
+
this.ruledOut.add(direction);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (this.directions.every(direction => this.ruledOut.has(direction))) {
|
|
106
|
+
this.setState('failed');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Travel along and across `direction` from the origin to `point`. */
|
|
111
|
+
project(direction, point) {
|
|
112
|
+
const dx = point.x - this.origin.x;
|
|
113
|
+
const dy = point.y - this.origin.y;
|
|
114
|
+
return direction === 'left' ? [-dx, dy] : direction === 'right' ? [dx, dy] : direction === 'up' ? [-dy, dx] : [dy, dx];
|
|
115
|
+
}
|
|
116
|
+
touchesEnded() {
|
|
117
|
+
// Recognized and waiting, it holds past the lift (FR15).
|
|
118
|
+
if (this.pending == null) {
|
|
119
|
+
this.setState('failed');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
reset() {
|
|
123
|
+
this.recognizedDirection = null;
|
|
124
|
+
this.ruledOut.clear();
|
|
125
|
+
this.last = null;
|
|
126
|
+
this.origin = {
|
|
127
|
+
x: 0,
|
|
128
|
+
y: 0
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Where on the segment from `start` to `end` (0 to 1) the value first
|
|
135
|
+
* reaches `limit`; 0 when it starts there, -1 when it never does.
|
|
136
|
+
*/
|
|
137
|
+
function segmentCrossing(start, end, limit) {
|
|
138
|
+
if (start >= limit) {
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
if (end < limit) {
|
|
142
|
+
return -1;
|
|
143
|
+
}
|
|
144
|
+
return (limit - start) / (end - start);
|
|
145
|
+
}
|
|
@@ -27,9 +27,13 @@ export declare class VelocityTracker {
|
|
|
27
27
|
* Record a position. Timestamps must not go backwards (an older sample is
|
|
28
28
|
* ignored), and a moved sample at the newest moved sample's timestamp
|
|
29
29
|
* replaces it. A sample at the newest position is not motion: it changes
|
|
30
|
-
* no velocity
|
|
30
|
+
* no velocity, unless `isMotion` says the contact moved anyway (a pinch's
|
|
31
|
+
* value holding while both fingers move, which reads as zero velocity for
|
|
32
|
+
* that interval).
|
|
31
33
|
*/
|
|
32
|
-
add(x: number, y: number, time: number
|
|
34
|
+
add(x: number, y: number, time: number, { isMotion }?: {
|
|
35
|
+
isMotion?: boolean;
|
|
36
|
+
}): void;
|
|
33
37
|
/** Record every sample in order. */
|
|
34
38
|
addSamples(samples: ReadonlyArray<TouchSample>): void;
|
|
35
39
|
/** The newest sample, if any. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VelocityTracker.d.ts","sourceRoot":"","sources":["../../src/gestures/VelocityTracker.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,6CAA6C;IAC7C,OAAO,CAAC,MAAM,CAA4B;IAC1C;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAqB;IAClC,0CAA0C;IAC1C,OAAO,CAAC,KAAK,CAAK;IAClB,mDAAmD;IACnD,OAAO,CAAC,GAAG,CAAe;IAC1B,OAAO,CAAC,WAAW,CAAe;gBAEtB,OAAO,GAAE,sBAA2B;IAIhD,2CAA2C;IAC3C,KAAK,IAAI,IAAI;IAQb
|
|
1
|
+
{"version":3,"file":"VelocityTracker.d.ts","sourceRoot":"","sources":["../../src/gestures/VelocityTracker.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,6CAA6C;IAC7C,OAAO,CAAC,MAAM,CAA4B;IAC1C;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAqB;IAClC,0CAA0C;IAC1C,OAAO,CAAC,KAAK,CAAK;IAClB,mDAAmD;IACnD,OAAO,CAAC,GAAG,CAAe;IAC1B,OAAO,CAAC,WAAW,CAAe;gBAEtB,OAAO,GAAE,sBAA2B;IAIhD,2CAA2C;IAC3C,KAAK,IAAI,IAAI;IAQb;;;;;;;OAOG;IACH,GAAG,CACD,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,MAAM,EACZ,EAAC,QAAgB,EAAC,GAAE;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAM,GAC5C,IAAI;IAwBP,oCAAoC;IACpC,UAAU,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,IAAI;IAMrD,iCAAiC;IACjC,IAAI,UAAU,IAAI,WAAW,GAAG,IAAI,CAEnC;IAED;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK;IAOrC;;;;OAIG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK;IAO1C,OAAO,CAAC,QAAQ;CAQjB"}
|
|
@@ -77,9 +77,13 @@ export class VelocityTracker {
|
|
|
77
77
|
* Record a position. Timestamps must not go backwards (an older sample is
|
|
78
78
|
* ignored), and a moved sample at the newest moved sample's timestamp
|
|
79
79
|
* replaces it. A sample at the newest position is not motion: it changes
|
|
80
|
-
* no velocity
|
|
80
|
+
* no velocity, unless `isMotion` says the contact moved anyway (a pinch's
|
|
81
|
+
* value holding while both fingers move, which reads as zero velocity for
|
|
82
|
+
* that interval).
|
|
81
83
|
*/
|
|
82
|
-
add(x, y, time
|
|
84
|
+
add(x, y, time, {
|
|
85
|
+
isMotion = false
|
|
86
|
+
} = {}) {
|
|
83
87
|
if (this.newest != null && time < this.newest.time) {
|
|
84
88
|
return;
|
|
85
89
|
}
|
|
@@ -89,7 +93,7 @@ export class VelocityTracker {
|
|
|
89
93
|
time
|
|
90
94
|
};
|
|
91
95
|
const last = this.moved[this.moved.length - 1];
|
|
92
|
-
if (last != null && x === last.x && y === last.y) {
|
|
96
|
+
if (last != null && x === last.x && y === last.y && !isMotion) {
|
|
93
97
|
return;
|
|
94
98
|
}
|
|
95
99
|
if (last != null && time === last.time) {
|