@@ -6,29 +6,38 @@ 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 ) ;
13+ if ( section === null ) {
14+ log . warning ( `LayoutSplitebar: selector ${ selector } not found` ) ;
15+ return ;
16+ }
17+
1318 const bar = el . querySelector ( ".layout-splitebar-body" ) ;
1419 let originX = 0 ;
1520 let width = 0 ;
1621 Drag . drag ( bar ,
1722 e => {
18- bar . classList . add ( 'drag' )
23+ section . classList . add ( 'drag' )
1924 width = parseInt ( getComputedStyle ( section ) . getPropertyValue ( '--bb-layout-sidebar-width' ) )
2025 originX = e . clientX || e . touches [ 0 ] . clientX
2126 } ,
2227 e => {
2328 const eventX = e . clientX || ( e . touches . length > 0 && e . touches [ 0 ] . clientX )
2429 const moveX = eventX - originX
2530 const newWidth = width + moveX
26- if ( newWidth >= min && newWidth <= max ) {
27- section . style . setProperty ( '--bb-layout-sidebar-width' , `${ newWidth } px` )
31+ if ( min > - 1 && newWidth < min ) {
32+ newWidth = min
33+ }
34+ if ( max > - 1 && newWidth > max ) {
35+ newWidth = max
2836 }
37+ section . style . setProperty ( '--bb-layout-sidebar-width' , `${ newWidth } px` )
2938 } ,
3039 e => {
31- bar . classList . remove ( 'drag' )
40+ section . classList . remove ( 'drag' )
3241 }
3342 )
3443}
0 commit comments