-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from DennisvHest/84-ability-to-change-the-wid…
…th-of-the-sidebar 84 ability to change the width of the sidebar
- Loading branch information
Showing
7 changed files
with
95 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,5 @@ | |
top: 0; | ||
width: 100%; | ||
height: auto; | ||
z-index: -1; | ||
filter: blur(10px); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
window.sideNavResizer = (function () { | ||
const minSideNavWidth = 250; | ||
const maxSideNavWidth = 700; | ||
|
||
let sideNavWidth = localStorage.getItem("sideNavWidth") ?? minSideNavWidth; | ||
|
||
setDrawerWidthNoThrottle(sideNavWidth); | ||
|
||
const setDrawerWidth = throttle(setDrawerWidthNoThrottle, 30); | ||
|
||
function setDrawerWidthNoThrottle(width) { | ||
// Set the side nav width to the current mouse position | ||
sideNavWidth = width; | ||
document.documentElement.style.setProperty("--main-drawer-width-left", `${width}px`); | ||
} | ||
|
||
function startSideNavResize(event) { | ||
// Start tracking mouse movement | ||
document.addEventListener("mousemove", onMouseMove); | ||
document.addEventListener("mouseup", stopSideNavResize); | ||
} | ||
|
||
function onMouseMove(event) { | ||
if (event.clientX >= minSideNavWidth && event.clientX <= maxSideNavWidth) | ||
setDrawerWidth(event.clientX); | ||
} | ||
|
||
function stopSideNavResize() { | ||
document.removeEventListener("mouseup", stopSideNavResize); | ||
document.removeEventListener("mousemove", onMouseMove); | ||
|
||
localStorage.setItem("sideNavWidth", sideNavWidth); | ||
} | ||
|
||
function throttle(mainFunction, delay) { | ||
let timerFlag = null; | ||
|
||
return (...args) => { | ||
if (timerFlag === null) | ||
mainFunction(...args); | ||
timerFlag = setTimeout(() => { | ||
timerFlag = null; | ||
}, delay); | ||
} | ||
}; | ||
|
||
function initialize() { | ||
const resizerHandle = document.querySelector(".resizer-handle"); | ||
resizerHandle.addEventListener("mousedown", startSideNavResize); | ||
} | ||
|
||
return { | ||
initialize: initialize | ||
} | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters