Skip to content

Commit

Permalink
add subtopic indent, use position fixed to help users scroll on the s…
Browse files Browse the repository at this point in the history
…idebar (#642)

* add subtopic indent, use position fixed to help users scroll on the sidebar

* fix lint
  • Loading branch information
beets authored Oct 23, 2020
1 parent 099e913 commit 9252c2a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 9 additions & 2 deletions static/css/place/place.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ $chart-border: 0.5px solid #dee2e6;

#topics .nav-item .nav-item a {
font-weight: 300;
padding: 0.25rem 0;
padding: 0.25rem 0 .25rem .5rem;
font-size: .8rem;
}

#topics a.active {
Expand Down Expand Up @@ -146,7 +147,6 @@ $chart-border: 0.5px solid #dee2e6;

.subtopic .row .col {
padding: 0.5rem;
margin-bottom: calc(.7rem + 10px); // height of feedback link + padding
}

.btn-dc {
Expand Down Expand Up @@ -254,6 +254,13 @@ $chart-border: 0.5px solid #dee2e6;
position: relative;
}

#sidebar-region.fixed {
position: fixed;
height: 100vh;
overflow-y: scroll;
top: 0;
}

#child-place-title {
font-weight: bold;
font-size: 14px;
Expand Down
12 changes: 11 additions & 1 deletion static/js/place/place.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ function updatePageLayoutState(): void {
function maybeToggleFixedSidebar(): void {
if (window.innerWidth < Y_SCROLL_WINDOW_BREAKPOINT) {
document.removeEventListener("scroll", adjustMenuPosition);
document.getElementById("sidebar-region").classList.remove("fixed");
return;
}
document.addEventListener("scroll", adjustMenuPosition);
document.getElementById("sidebar-region").style.width =
document.getElementById("sidebar-top-spacer").offsetWidth + "px";
adjustMenuPosition();
}

/**
Expand All @@ -78,10 +82,16 @@ function adjustMenuPosition(): void {
const calcTop = window.scrollY - yScrollLimit - Y_SCROLL_MARGIN;
if (calcTop > sidebarTopMax) {
topicsEl.style.top = sidebarTopMax + "px";
topicsEl.classList.remove("fixed");
return;
}
topicsEl.style.top = calcTop + "px";
topicsEl.classList.add("fixed");
if (topicsEl.style.top != "0") {
topicsEl.style.top = "0";
topicsEl.scrollTop = 0;
}
} else {
topicsEl.classList.remove("fixed");
topicsEl.style.top = "0";
}
}
Expand Down

0 comments on commit 9252c2a

Please sign in to comment.