Skip to content

Commit 9f67f23

Browse files
committed
feat: 支持默认值
1 parent 42d8583 commit 9f67f23

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/BootstrapBlazor/Components/Layout/LayoutSplitebar.razor.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export function init(id) {
66
return;
77
}
88

9-
const min = parseFloat(el.getAttribute("data-bb-min") ?? "0");
10-
const max = parseFloat(el.getAttribute("data-bb-max") ?? "0");
9+
const min = parseFloat(el.getAttribute("data-bb-min") ?? "-1");
10+
const max = parseFloat(el.getAttribute("data-bb-max") ?? "-1");
1111
const selector = el.getAttribute("data-bb-selector") ?? ".layout";
1212
const section = document.querySelector(selector);
1313
const bar = el.querySelector(".layout-splitebar-body");
@@ -23,9 +23,13 @@ export function init(id) {
2323
const eventX = e.clientX || (e.touches.length > 0 && e.touches[0].clientX)
2424
const moveX = eventX - originX
2525
const newWidth = width + moveX
26-
if (newWidth >= min && newWidth <= max) {
27-
section.style.setProperty('--bb-layout-sidebar-width', `${newWidth}px`)
26+
if (min > -1 && newWidth < min) {
27+
newWidth = min
2828
}
29+
if (max > -1 && newWidth > max) {
30+
newWidth = max
31+
}
32+
section.style.setProperty('--bb-layout-sidebar-width', `${newWidth}px`)
2933
},
3034
e => {
3135
bar.classList.remove('drag')

0 commit comments

Comments
 (0)