mirror of
https://github.com/danbulant/dribbblish-dynamic-theme
synced 2026-05-24 12:35:05 +00:00
Automatically hide sidebar playlist shadows when scrolled all the way up / down
This commit is contained in:
parent
abe0d22e43
commit
c6a7fa4e7d
2 changed files with 40 additions and 6 deletions
|
|
@ -180,18 +180,43 @@ waitForElement([
|
|||
.observe(listElem, {childList: true});
|
||||
});
|
||||
|
||||
waitForElement([".main-rootlist-rootlist", ".main-rootlist-wrapper > :nth-child(2) > :first-child"], ([rootlist]) => {
|
||||
function checkSidebarPlaylistScroll() {
|
||||
const topDist = rootlist.getBoundingClientRect().top - document.querySelector(".main-rootlist-wrapper > :nth-child(2) > :first-child").getBoundingClientRect().top;
|
||||
const bottomDist = document.querySelector(".main-rootlist-wrapper > :nth-child(2) > :last-child").getBoundingClientRect().bottom - rootlist.getBoundingClientRect().bottom;
|
||||
|
||||
rootlist.classList.remove("no-top-shadow", "no-bottom-shadow");
|
||||
if (topDist < 10) rootlist.classList.add("no-top-shadow");
|
||||
if (bottomDist < 10) rootlist.classList.add("no-bottom-shadow");
|
||||
}
|
||||
checkSidebarPlaylistScroll();
|
||||
|
||||
// Use Interval because scrolling takes a while and getBoundingClientRect() gets position at the moment of calling, so the interval keeps calling for 1s
|
||||
let c = 0;
|
||||
let interval;
|
||||
rootlist.addEventListener("wheel", () => {
|
||||
checkSidebarPlaylistScroll();
|
||||
c = 0;
|
||||
if (interval == null)
|
||||
interval = setInterval(() => {
|
||||
if (c > 20) {
|
||||
clearInterval(interval);
|
||||
interval = null;
|
||||
return;
|
||||
}
|
||||
|
||||
checkSidebarPlaylistScroll();
|
||||
c++;
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
|
||||
waitForElement([".Root__main-view"], ([mainView]) => {
|
||||
const shadow = document.createElement("div");
|
||||
shadow.id = "dribbblish-back-shadow";
|
||||
mainView.prepend(shadow);
|
||||
});
|
||||
|
||||
waitForElement([".main-rootlist-rootlistPlaylistsScrollNode"], (queries) => {
|
||||
const fade = document.createElement("div");
|
||||
fade.id = "dribbblish-sidebar-fade-in";
|
||||
queries[0].append(fade);
|
||||
});
|
||||
|
||||
waitForElement([
|
||||
".Root__nav-bar .LayoutResizer__input, .Root__nav-bar .LayoutResizer__resize-bar input"
|
||||
], ([resizer]) => {
|
||||
|
|
|
|||
9
user.css
9
user.css
|
|
@ -405,6 +405,15 @@ html.sidebar-hide-text .GlueDropTarget span {
|
|||
left: 0px;
|
||||
right: 0px;
|
||||
pointer-events: none;
|
||||
transition: height 0.5s ease;
|
||||
}
|
||||
|
||||
.main-rootlist-rootlist.no-top-shadow::before {
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
.main-rootlist-rootlist.no-bottom-shadow::after {
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
.main-rootlist-rootlist::before {
|
||||
|
|
|
|||
Loading…
Reference in a new issue