mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Merge branch 'master' into translations
This commit is contained in:
@@ -82,10 +82,14 @@ main img {
|
||||
border: 2px solid #fc0
|
||||
}
|
||||
|
||||
.posts.exceptions {
|
||||
.posts.interrupts {
|
||||
border: 2px solid #f66;
|
||||
}
|
||||
|
||||
.posts.multitasking {
|
||||
border: 2px solid #556b2f;
|
||||
}
|
||||
|
||||
.posts hr {
|
||||
margin: 2rem 0;
|
||||
}
|
||||
@@ -122,10 +126,14 @@ main img {
|
||||
color: #990;
|
||||
}
|
||||
|
||||
.post-category.exceptions {
|
||||
.post-category.interrupts {
|
||||
color: #f33;
|
||||
}
|
||||
|
||||
.post-category.multitasking {
|
||||
color: #556b2f;
|
||||
}
|
||||
|
||||
.post-footer-support {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
@@ -193,19 +201,26 @@ aside#all-posts-link {
|
||||
width: 12rem;
|
||||
position: sticky;
|
||||
float: left;
|
||||
top: 1rem;
|
||||
top: 3.5rem;
|
||||
margin-top: -4rem;
|
||||
margin-left: -15rem;
|
||||
font-size: 90%;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
#toc-aside li > a, #toc-aside h2 {
|
||||
opacity: .5;
|
||||
transition: opacity .5s;
|
||||
}
|
||||
|
||||
#toc-aside:hover {
|
||||
#toc-aside:hover li > a, #toc-aside:hover h2 {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#toc-aside li.active > a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#toc-aside h2 {
|
||||
font-size: 110%;
|
||||
margin-bottom: .2rem;
|
||||
@@ -217,7 +232,7 @@ aside#all-posts-link {
|
||||
list-style:none;
|
||||
}
|
||||
|
||||
#toc-aside ol li:before {
|
||||
#toc-aside ol li a:before {
|
||||
content: "";
|
||||
border-color: transparent #008eef;
|
||||
border-style: solid;
|
||||
@@ -263,11 +278,10 @@ aside#all-posts-link {
|
||||
}
|
||||
|
||||
aside#all-posts-link {
|
||||
float: left;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: -15rem;
|
||||
position: fixed;
|
||||
top: 1.25rem;
|
||||
margin-top: 0;
|
||||
margin-left: -15rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ window.onload = function() {
|
||||
|
||||
if (container != null) {
|
||||
resize_toc(container);
|
||||
toc_scroll_position(container);
|
||||
window.onscroll = function() { toc_scroll_position(container) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,3 +26,38 @@ function resize_toc(container) {
|
||||
resizeId = setTimeout(resize, 300);
|
||||
};
|
||||
}
|
||||
|
||||
function toc_scroll_position(container) {
|
||||
if (container.offsetParent === null) {
|
||||
// skip computation if ToC is not visible
|
||||
return;
|
||||
}
|
||||
var items = container.querySelectorAll("li")
|
||||
|
||||
// remove active class for all items
|
||||
for (item of container.querySelectorAll("li")) {
|
||||
item.classList.remove("active");
|
||||
}
|
||||
|
||||
// look for active item
|
||||
var site_offset = document.documentElement.scrollTop;
|
||||
var current_toc_item = null;
|
||||
for (item of container.querySelectorAll("li")) {
|
||||
if (item.offsetParent === null) {
|
||||
// skip items that are not visible
|
||||
continue;
|
||||
}
|
||||
var anchor = item.firstElementChild.getAttribute("href");
|
||||
var heading = document.querySelector(anchor);
|
||||
if (heading.offsetTop <= (site_offset + document.documentElement.clientHeight / 3)) {
|
||||
current_toc_item = item;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// set active class for current ToC item
|
||||
if (current_toc_item != null) {
|
||||
current_toc_item.classList.add("active");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user