Apply suggestions from code review

Co-authored-by: Cory LaViska <cory@abeautifulsite.net>
pull/2340/head
Auri Collings 2025-02-03 13:10:16 -08:00 zatwierdzone przez GitHub
rodzic 87917cdc18
commit be86c11a4a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 5 dodań i 3 usunięć

Wyświetl plik

@ -255,7 +255,7 @@ Or, if you want to snap the panel to every `100px` interval, as well as at 50% o
```html:preview
<div class="split-panel-snapping-repeat">
<sl-split-panel snap="repeat(16px) 50%">
<sl-split-panel snap="repeat(100px) 50%">
<div
slot="start"
style="height: 150px; background: var(--sl-color-neutral-50); display: flex; align-items: center; justify-content: center; overflow: hidden;"
@ -278,9 +278,12 @@ Or, if you want to snap the panel to every `100px` interval, as well as at 50% o
</style>
```
### 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.

Wyświetl plik

@ -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(" ");