Update
This commit is contained in:
parent
b9db39443a
commit
4841b7cd05
|
@ -19,6 +19,8 @@
|
||||||
let headingsObjects = {}
|
let headingsObjects = {}
|
||||||
let contentHeadings = []
|
let contentHeadings = []
|
||||||
let contentTable
|
let contentTable
|
||||||
|
let lastTop = 0
|
||||||
|
let margin = 0
|
||||||
|
|
||||||
const htmlDelims = ["ul","ol"]
|
const htmlDelims = ["ul","ol"]
|
||||||
getData("/assets/manifesto.txt",function(response) {
|
getData("/assets/manifesto.txt",function(response) {
|
||||||
|
@ -94,10 +96,31 @@
|
||||||
function goToChapter(id) {
|
function goToChapter(id) {
|
||||||
headingsObjects[id].scrollIntoView({block: 'start'}, true);
|
headingsObjects[id].scrollIntoView({block: 'start'}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addEventListener("scroll", (event) => {
|
addEventListener("scroll", (event) => {
|
||||||
contentTable.style.marginTop = -Math.min(px2rem(window.pageYOffset),5) + "rem"
|
let top = px2rem(window.scrollY)
|
||||||
|
if (top>lastTop || top<5) {
|
||||||
|
if (contentTable.offsetHeight < window.innerHeight) {
|
||||||
|
margin = -Math.min(px2rem(window.scrollY),5)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let dif = px2rem(contentTable.offsetHeight - window.innerHeight)
|
||||||
|
margin = -Math.min(px2rem(window.scrollY),5 + dif + 2.5)
|
||||||
|
}
|
||||||
|
contentTable.style.marginTop = margin + "rem"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (contentTable.offsetHeight> window.innerHeight) {
|
||||||
|
if (margin<-5) {
|
||||||
|
margin = margin + (lastTop-top)
|
||||||
|
contentTable.style.marginTop = margin + "rem"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
contentTable.style.marginTop = "-5rem"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastTop = px2rem(window.scrollY)
|
||||||
})
|
})
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
@ -193,7 +216,6 @@
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
width: 20rem;
|
width: 20rem;
|
||||||
height: max-content;
|
height: max-content;
|
||||||
max-height: calc(100vh - 2.5rem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#toggle-content {
|
#toggle-content {
|
||||||
|
@ -217,10 +239,7 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow-y: scroll;
|
|
||||||
overflow-x: visible;
|
|
||||||
height: max-content;
|
height: max-content;
|
||||||
max-height: 100%;
|
|
||||||
padding-right: 1.2rem;
|
padding-right: 1.2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue