This commit is contained in:
a-ill 2023-06-26 19:26:50 +03:00
parent 31eed5039a
commit df0f0766ca
2 changed files with 43 additions and 14 deletions

View File

@ -21,6 +21,8 @@
let contentTable let contentTable
let lastTop = 0 let lastTop = 0
let margin = 0 let margin = 0
let root
let main
const htmlDelims = ["ul","ol"] const htmlDelims = ["ul","ol"]
getData("/assets/manifesto.txt",function(response) { getData("/assets/manifesto.txt",function(response) {
@ -98,29 +100,50 @@
} }
addEventListener("scroll", (event) => { addEventListener("scroll", (event) => {
if (window.innerWidth>1080) {
let top = px2rem(window.scrollY) let top = px2rem(window.scrollY)
if (top>lastTop || top<5) { let textBottom = px2rem(root.getBoundingClientRect().bottom + window.scrollY)
if (contentTable.offsetHeight < window.innerHeight) { let tableBottom = px2rem(contentTable.getBoundingClientRect().bottom + window.scrollY)
if ((top>lastTop && top<5) || (top<lastTop && top<5)) {
margin = -Math.min(px2rem(window.scrollY),5) margin = -Math.min(px2rem(window.scrollY),5)
} }
else if (tableBottom >= (textBottom - 1.5)) {
margin = margin - (tableBottom - (textBottom - 1.5))
}
else { else {
if (margin>-5) {
margin = -5
}
if (top<5 && top!=0) {
let dif = px2rem(contentTable.offsetHeight - window.innerHeight) let dif = px2rem(contentTable.offsetHeight - window.innerHeight)
margin = -Math.min(px2rem(window.scrollY),5 + dif + 2.5) margin = -Math.min(px2rem(window.scrollY),5 + dif + 2.5)
} }
contentTable.style.marginTop = margin + "rem" else if (top<lastTop || margin==0) {
if (margin <-5) {
margin = margin + (lastTop-top)
}
else {
margin = -5
}
} }
else { else {
if (contentTable.offsetHeight > window.innerHeight) { if (contentTable.offsetHeight > window.innerHeight) {
if (margin<-5) { let dif = px2rem(contentTable.offsetHeight) - px2rem(window.innerHeight)
if (margin > -(dif+8)) {
margin = margin + (lastTop-top) margin = margin + (lastTop-top)
contentTable.style.marginTop = margin + "rem"
} }
else { else {
contentTable.style.marginTop = "-5rem" margin = -(dif+8)
} }
} }
} }
}
contentTable.style.marginTop = margin + "rem"
lastTop = px2rem(window.scrollY) lastTop = px2rem(window.scrollY)
}
else {
contentTable.style.marginTop = "0rem"
}
}) })
onMount(() => { onMount(() => {
@ -133,7 +156,7 @@
}) })
</script> </script>
<div id="container"> <div id="container" bind:this={root}>
<div id="text-container"> <div id="text-container">
{#key key} {#key key}
<div bind:this={contentTable} id="table-content"> <div bind:this={contentTable} id="table-content">
@ -161,7 +184,7 @@
{/each} {/each}
</div> </div>
</div> </div>
<div id="main"> <div id="main" bind:this={main}>
{#each manifesto as line} {#each manifesto as line}
{#if line!==""} {#if line!==""}
{#if typeof (line === 'object') && (Object.keys(line)[0]=="ul")} {#if typeof (line === 'object') && (Object.keys(line)[0]=="ul")}
@ -193,6 +216,8 @@
{@html line} {@html line}
</p> </p>
{/if} {/if}
{:else if false}
<b></b>
{/if} {/if}
{/each} {/each}
</div> </div>
@ -204,6 +229,10 @@
<style> <style>
@import '/css/common.css'; @import '/css/common.css';
#main b {
color: #d50400;
}
#table-content { #table-content {
position: fixed; position: fixed;
display: flex; display: flex;

File diff suppressed because one or more lines are too long