Skip to content

Commit b00dfd3

Browse files
Matthew HollowayMatthew Holloway
authored andcommitted
feat: Overflow shadows
1 parent 3a839ec commit b00dfd3

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

ietf/static/css/ietf.scss

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,3 +1188,20 @@ blockquote {
11881188
padding-left: 1rem;
11891189
border-left: solid 1px var(--bs-body-color);
11901190
}
1191+
1192+
.overflow-shadows {
1193+
transition: box-shadow 0.5s;
1194+
}
1195+
1196+
.overflow-shadows--both {
1197+
box-shadow: inset 0px 21px 18px -20px var(--bs-body-color),
1198+
inset 0px -21px 18px -20px var(--bs-body-color);
1199+
}
1200+
1201+
.overflow-shadows--top-only {
1202+
box-shadow: inset 0px 21px 18px -20px var(--bs-body-color);
1203+
}
1204+
1205+
.overflow-shadows--bottom-only {
1206+
box-shadow: inset 0px -21px 18px -20px var(--bs-body-color);
1207+
}

ietf/static/js/ietf.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,27 @@ $(document)
9191
// });
9292
});
9393

94+
function overflowShadows(el) {
95+
function handleScroll(){
96+
const canScrollUp = el.scrollTop > 0
97+
const canScrollDown = el.offsetHeight + el.scrollTop < el.scrollHeight
98+
el.classList.toggle("overflow-shadows--both", canScrollUp && canScrollDown)
99+
el.classList.toggle("overflow-shadows--top-only", canScrollUp && !canScrollDown)
100+
el.classList.toggle("overflow-shadows--bottom-only", !canScrollUp && canScrollDown)
101+
}
102+
103+
el.addEventListener("scroll", handleScroll, {passive: true})
104+
handleScroll()
105+
106+
const observer = new IntersectionObserver(handleScroll)
107+
observer.observe(el) // el won't have scrollTop etc when hidden, so we need to recalculate when it's revealed
108+
109+
return () => {
110+
el.removeEventListener("scroll", handleScroll)
111+
observer.unobserve(el)
112+
}
113+
}
114+
94115
$(document)
95116
.ready(function () {
96117
// load data for the menu
@@ -108,7 +129,7 @@ $(document)
108129
}
109130
attachTo.find(".dropdown-menu")
110131
.remove();
111-
var menu = ['<ul class="dropdown-menu ms-n1 mt-n1">'];
132+
var menu = ['<ul class="dropdown-menu ms-n1 mt-n1 overflow-shadows">'];
112133
var groups = data[parentId];
113134
var gtype = "";
114135
for (var i = 0; i < groups.length; ++i) {
@@ -127,6 +148,8 @@ $(document)
127148
attachTo.closest(".dropdown-menu");
128149
}
129150
attachTo.append(menu.join(""));
151+
152+
attachTo.find(".overflow-shadows").each(function(){ overflowShadows(this)})
130153
}
131154
}
132155
});

0 commit comments

Comments
 (0)