Skip to content

feat: add snapToPoint prop for custom snap behavior - #887

Merged
tomkp merged 3 commits into
tomkp:masterfrom
phryneas:pr/snapToPoint
Oct 26, 2026
Merged

tomkp merged 3 commits into
tomkp:masterfrom
phryneas:pr/snapToPoint

Conversation

@phryneas

@phryneas phryneas commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Sorry for not opening an issue on this first - I needed it anyways as a local patch, so I though I'd just directly open a PR. :)

This allows userland to override default snapToPoint behavior - in our case, we had a sidebar that should snap closed beyond a certain size and back to open when dragged sufficiently far, but not snap to "minimal open width" when the cursor was coming to "minimal open width" from the right, only from the left.

phryneas and others added 3 commits May 21, 2026 17:46
Allows callers to override the built-in snap logic with their own
function, called with (value, snapPoints, snapTolerance) for each pane
size during drag. Only invoked when snapPoints is non-empty; defaults
to the behavior when omitted.
# Conflicts:
#	src/hooks/useResizer.test.ts
Since tomkp#888, snapping applies to the pane before the dragged divider and the next pane absorbs the difference, so the custom function is called once per move rather than once per pane.
@tomkp

tomkp commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thanks! I merged master in and updated one test: since #888, snapToPoint is only called for the pane before the dragged divider, so once per move rather than once per pane. Merging now.

@tomkp
tomkp merged commit a42a572 into tomkp:master Oct 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants