mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-14 06:42:35 +00:00
Disable text selection and CSS transition while resizing sidebar
This commit is contained in:
parent
3d37e24c14
commit
3d8db7f25c
3 changed files with 11 additions and 4 deletions
|
@ -480,12 +480,14 @@ function playpen_text(playpen) {
|
||||||
function initResize(e) {
|
function initResize(e) {
|
||||||
window.addEventListener('mousemove', resize, false);
|
window.addEventListener('mousemove', resize, false);
|
||||||
window.addEventListener('mouseup', stopResize, false);
|
window.addEventListener('mouseup', stopResize, false);
|
||||||
|
html.classList.add('sidebar-resizing');
|
||||||
}
|
}
|
||||||
function resize(e) {
|
function resize(e) {
|
||||||
document.documentElement.style.setProperty('--sidebar-width', (e.clientX - sidebar.offsetLeft) + 'px');
|
document.documentElement.style.setProperty('--sidebar-width', (e.clientX - sidebar.offsetLeft) + 'px');
|
||||||
}
|
}
|
||||||
//on mouseup remove windows functions mousemove & mouseup
|
//on mouseup remove windows functions mousemove & mouseup
|
||||||
function stopResize(e) {
|
function stopResize(e) {
|
||||||
|
html.classList.remove('sidebar-resizing');
|
||||||
window.removeEventListener('mousemove', resize, false);
|
window.removeEventListener('mousemove', resize, false);
|
||||||
window.removeEventListener('mouseup', stopResize, false);
|
window.removeEventListener('mouseup', stopResize, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,13 @@ ul#searchresults span.teaser em {
|
||||||
background-color: var(--sidebar-bg);
|
background-color: var(--sidebar-bg);
|
||||||
color: var(--sidebar-fg);
|
color: var(--sidebar-fg);
|
||||||
}
|
}
|
||||||
.js .sidebar {
|
.sidebar-resizing {
|
||||||
|
-moz-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.js:not(.sidebar-resizing) .sidebar {
|
||||||
transition: transform 0.3s; /* Animation: slide away */
|
transition: transform 0.3s; /* Animation: slide away */
|
||||||
}
|
}
|
||||||
.sidebar code {
|
.sidebar code {
|
||||||
|
|
|
@ -51,7 +51,7 @@ a.header:target h4:before {
|
||||||
.page-wrapper {
|
.page-wrapper {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
.js .page-wrapper {
|
.js:not(.sidebar-resizing) .page-wrapper {
|
||||||
transition: margin-left 0.3s ease, transform 0.3s ease; /* Animation: slide away */
|
transition: margin-left 0.3s ease, transform 0.3s ease; /* Animation: slide away */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,4 +141,3 @@ blockquote {
|
||||||
.tooltipped .tooltiptext {
|
.tooltipped .tooltiptext {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue