Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/public-drag-to-snap-points.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@astryxdesign/core': patch
'@astryxdesign/cli': patch
---

[feat] `createDragToSnapPoints` and its hook `useDragToSnapPoints` let a drag move an element along one axis and settle it on snap points (px offsets from its resting position) at the release: the nearest one, the next one in its direction after a flick faster than `flickThreshold` (default 1008 px/s), or the one it started from when the release moves back. The settle continues the release velocity, `settleTo(index)` settles without a drag, and `onSettle(index)` reports where it landed. `createDragToSnapPoints` is exported from the package root and `useDragToSnapPoints` from `@astryxdesign/core/hooks`; the CLI's templates gain a playing-card example of each.

@vjeux
8 changes: 8 additions & 0 deletions .changeset/public-pan-gesture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@astryxdesign/core': patch
'@astryxdesign/cli': patch
---

[feature] `createPanGesture(element, {axis?, onPan})` and `usePanGesture(ref, {axis?, onPan})` report a drag on an element as values: `onPan` gets `{state, translation, velocity}` as the drag begins, changes, ends at the release, or is cancelled, and a finger, a mouse and a pen all drive it. `axis` limits the drag to `'x'` or `'y'`; a drag along the other axis is not reported. `translation` counts from where the drag began, so an element that follows it does not jump, and `velocity` at `ended` is the release velocity in pixels per second. The drag claims its touch at UIKit's 10 pt and leaves presses and long presses alone. `destroy()` removes every listener; the hook creates one pan for the element behind `ref` and destroys it at unmount.

@vjeux
4 changes: 4 additions & 0 deletions apps/sandbox/scripts/next-export-routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@
"/templates/DividerShowcase/",
"/templates/DividerVariants/",
"/templates/DividerVertical/",
"/templates/DragToSnapPointsCard/",
"/templates/DragToSnapPointsCardVanilla/",
"/templates/DrawerForm/",
"/templates/DrawerHeaderShowcase/",
"/templates/DrawerHeaderSubtitleEndContent/",
Expand Down Expand Up @@ -470,6 +472,8 @@
"/templates/PaginationPageSize/",
"/templates/PaginationVariants/",
"/templates/PaginationWithTable/",
"/templates/PanPlayingCard/",
"/templates/PanPlayingCardVanilla/",
"/templates/PopoverBottomSheetAlternative/",
"/templates/PopoverConfirmAction/",
"/templates/PopoverFilterPanel/",
Expand Down
40 changes: 40 additions & 0 deletions internal/shadcn-registry/routes.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,16 @@
"path": "examples/create-animator/playing-cards-in-plain-java-script",
"aliases": []
},
{
"name": "example-create-drag-to-snap-points-playing-card-in-plain-java-script",
"path": "examples/create-drag-to-snap-points/playing-card-in-plain-java-script",
"aliases": []
},
{
"name": "example-create-pan-gesture-a-playing-card-without-react",
"path": "examples/create-pan-gesture/a-playing-card-without-react",
"aliases": []
},
{
"name": "example-date-input-clearable",
"path": "examples/date-input/clearable",
Expand Down Expand Up @@ -3696,6 +3706,11 @@
"path": "examples/use-container-reveal/reveal-on-hover-row-actions",
"aliases": []
},
{
"name": "example-use-drag-to-snap-points-playing-card-on-three-places",
"path": "examples/use-drag-to-snap-points/playing-card-on-three-places",
"aliases": []
},
{
"name": "example-use-focus-trap-quick-edit-panel",
"path": "examples/use-focus-trap/quick-edit-panel",
Expand Down Expand Up @@ -3766,6 +3781,11 @@
"path": "examples/use-overflow/editor-toolbar",
"aliases": []
},
{
"name": "example-use-pan-gesture-a-playing-card",
"path": "examples/use-pan-gesture/a-playing-card",
"aliases": []
},
{
"name": "example-use-popover-quick-actions",
"path": "examples/use-popover/quick-actions",
Expand Down Expand Up @@ -3881,6 +3901,16 @@
"path": "hooks/create-animator",
"aliases": []
},
{
"name": "hook-create-drag-to-snap-points",
"path": "hooks/create-drag-to-snap-points",
"aliases": []
},
{
"name": "hook-create-pan-gesture",
"path": "hooks/create-pan-gesture",
"aliases": []
},
{
"name": "hook-use-animated-layout",
"path": "hooks/use-animated-layout",
Expand Down Expand Up @@ -3936,6 +3966,11 @@
"path": "hooks/use-dev-warning",
"aliases": []
},
{
"name": "hook-use-drag-to-snap-points",
"path": "hooks/use-drag-to-snap-points",
"aliases": []
},
{
"name": "hook-use-entry-animation",
"path": "hooks/use-entry-animation",
Expand Down Expand Up @@ -4061,6 +4096,11 @@
"path": "hooks/use-overflow",
"aliases": []
},
{
"name": "hook-use-pan-gesture",
"path": "hooks/use-pan-gesture",
"aliases": []
},
{
"name": "hook-use-popover",
"path": "hooks/use-popover",
Expand Down
Loading