You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use theme to enforce min-width in CSS when the sidebar is open.
Also calculate the "breakpoint" on window resize, to half the minimum width of the sidebar, converted to a percentage. Otherwise, the breakpoint would move when the window is resized.
<script>constsidebarMinWidth=200// in pxletwindowWidth// in px// Calculate "breakpoint" on window resize (half the width of the sidebar,// converted to a percentage of the window's inner width)letsidebarSnap=0
$: sidebarSnap=((sidebarMinWidth/windowWidth)*100)/2letsidebarState='open'constonSidebarResize=(event)=>{const{ size, snap }=event.detail[0]if(sidebarState==='open'&&size<snap){sidebarState='closed'}elseif(sidebarState==='closed'&&size>snap){sidebarState='open'}}</script><svelte:windowbind:innerWidth={windowWidth} />
<Splitpanestheme={sidebarState}on:resize={onSidebarResize}><Panesize={0}minSize={0}maxSize={80}snapSize={sidebarSnap}class="sidebar"></Pane><Pane></Pane></Splitpanes><stylegloballang="scss">
.splitpanes.open .sidebar {
min-width: 200px;
}
</style>
Use
theme
to enforcemin-width
in CSS when the sidebar is open.Also calculate the "breakpoint" on window resize, to half the minimum width of the sidebar, converted to a percentage. Otherwise, the breakpoint would move when the window is resized.
Source: orefalo#37 (comment)
The text was updated successfully, but these errors were encountered: