Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Continuing on from #1639, this PR adds new functionality to
SlSplitPanel
to allow it to have more flexible snapping logic, which allows it to function in more domains. For example, use-cases where the panel must always snap to specific percentage intervals, or where the panel must snap to the start or end of its region, but not in-between.This is my first PR to this project. I tried to follow the existing code style as closely as possible, but please let me know if there's anything that could be improved for this PR to be merged.
Changes
sl-split-panel
's snap property to accept a string in the form ofrepeat(50px)
orrepeat(10%)
, which creates uniformly distributed snap points. e.g. a 450px wide split panel withsnap
set torepeat(100px)
would generate snap points at100px 200px 300px 400px
.SlSplitPanel.snap
to be set to a function to fully customize snap behaviour, allowing for logic such aspanel.snap = ({ pos, size }) => (pos < size / 2) ? 100 : (size - 100)
to define a split panel which snaps 100px from the left, and 100px from the right.snapThreshold = Infinity
to behave as you would intuitively expect it to and snap to the closest point instead of always the first.