This commit is contained in:
恍兮惚兮 2024-07-19 13:58:43 +08:00
parent f37f8c664c
commit 98fe465e95
2 changed files with 39 additions and 2 deletions

View File

@ -38,7 +38,35 @@ window.$docsify = {
},
executeScript: true,
plugins: [
function (hook, vm) {
hook.doneEach(() => {
var sidebar = document.getElementsByClassName("sidebar")[0];
var resizeBar = document.createElement('div');
resizeBar.classList.add('sidebarresizer')
sidebar.appendChild(resizeBar);
var startX, startWidth;
resizeBar.addEventListener('mousedown', function (e) {
startX = e.clientX;
startWidth = sidebar.offsetWidth;
e.preventDefault();
});
document.addEventListener('mousemove', function (e) {
if (startX) {
var newWidth = startWidth + (e.clientX - startX);
document.documentElement.style.setProperty('--sidebar-width', sidebar.style.width);
sidebar.style.width = Math.max(200, newWidth) + 'px';
}
});
document.addEventListener('mouseup', function () {
startX = null;
});
})
},
]
}
let dropdowns = document.getElementsByClassName('dropdown')
@ -112,4 +140,4 @@ window.onpopstate = function (event) {
}
}
};
};

View File

@ -108,6 +108,15 @@
top: 50px;
}
.sidebarresizer {
width: 5px;
height: 100%;
position: absolute;
right: 0;
top: 0;
cursor: ew-resize;
}
.github-corner {
position: fixed;
top: 50px;