From be86c11a4a2287162aa0e71de4c78b057a664181 Mon Sep 17 00:00:00 2001 From: Auri Collings Date: Mon, 3 Feb 2025 13:10:16 -0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Cory LaViska --- docs/pages/components/split-panel.md | 7 +++++-- src/components/split-panel/split-panel.component.ts | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/pages/components/split-panel.md b/docs/pages/components/split-panel.md index 54071fbd..46a12deb 100644 --- a/docs/pages/components/split-panel.md +++ b/docs/pages/components/split-panel.md @@ -255,7 +255,7 @@ Or, if you want to snap the panel to every `100px` interval, as well as at 50% o ```html:preview
- +
``` +### Using a Custom Snap Function + You can also implement a custom snap function which controls the snapping manually. To do this, you need to acquire a reference to the element in Javascript and set the `snap` property. For example, if you want to snap the divider to either `100px` from the left or `100px` from the right, you can set the `snap` property to a function encoding that logic. -```panel.snap = ({ pos, size }) => (pos < size / 2) ? 100 : (size - 100)``` +```js +panel.snap = ({ pos, size }) => (pos < size / 2) ? 100 : (size - 100) Note that the `snap-threshold` property will not automatically be applied if `snap` is set to a function. Instead, the function itself must handle applying the threshold if desired, and is passed a `snapThreshold` member with its parameters. diff --git a/src/components/split-panel/split-panel.component.ts b/src/components/split-panel/split-panel.component.ts index f5ab4484..6abab1d3 100644 --- a/src/components/split-panel/split-panel.component.ts +++ b/src/components/split-panel/split-panel.component.ts @@ -97,7 +97,6 @@ export default class SlSplitPanel extends ShoelaceElement { * @param snap - The snap string. * @returns a `SnapFunction` representing the snap string's logic. */ - private toSnapFunction(snap: string): SnapFunction { const snapPoints = snap.split(" ");