better scrolling
This commit is contained in:
1 parent
f11be699b8
commit
b036b9289c
3 files changed
+50
-34
No files matched your search
+7
-13
@@ -37,9 +37,9 @@
|
||||
<object type="image/svg+xml" data="/media/stripes_secondary.svg"></object>
|
||||
</div>
|
||||
<div class="panes">
|
||||
<div class="pane" id="about">
|
||||
<div class="pane about" data-id="about">
|
||||
<div class="header">
|
||||
<div class="text big typein" data-content="Hi, I'm Mathew"></div>
|
||||
<div class="text big typein" data-content="Hi, I'm Mathew">​</div>
|
||||
<div class="text smol">I aspire to be a developer/sysadmin</div>
|
||||
<div class="text smolest">I usually work with JavaScript or Python. My sysadmin experience is currently
|
||||
limited to a
|
||||
@@ -58,11 +58,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pane" id="projects">
|
||||
<div class="pane projects" data-id="projects">
|
||||
work in progress
|
||||
</div>
|
||||
|
||||
<div class="pane" id="index">
|
||||
<div class="pane index" data-id="index">
|
||||
<div class="head">
|
||||
<div class="description active">
|
||||
<div class="title">Choose an app</div>
|
||||
@@ -97,17 +97,11 @@
|
||||
title: 'send.mtps.pl',
|
||||
content: "Self hostowany serwer Firefox Send. Szyfrowany upload plików, z hasłem i datą wygaśnięcia",
|
||||
link: 'https://send.mtps.pl/'
|
||||
},
|
||||
{
|
||||
name: 'mc',
|
||||
title: 'mc2.mtps.pl',
|
||||
content: "Serwer Minecraft. Koronawirus, edycja nr 6.",
|
||||
link: 'https://mc.mtps.pl/mc2/dynmap'
|
||||
},
|
||||
}
|
||||
]
|
||||
|
||||
const head = document.querySelector('#index>.head'),
|
||||
grid = document.querySelector('#index>.grid')
|
||||
const head = document.querySelector('.pane.index>.head'),
|
||||
grid = document.querySelector('.pane.index>.grid')
|
||||
|
||||
for(let app of apps){
|
||||
let description = document.createElement('div'),
|
||||
|
||||
@@ -1,25 +1,32 @@
|
||||
const Panes = {
|
||||
active: null,
|
||||
scrollTimeout: null,
|
||||
|
||||
switch(target) {
|
||||
if (target == this.active) return
|
||||
this.active = target
|
||||
document.querySelector('.button.active').classList.remove('active')
|
||||
document.querySelector(`.button[data-target=${target}]`).classList.add('active')
|
||||
},
|
||||
|
||||
scrollTo(target) {
|
||||
clearTimeout(this.scrollTimeout)
|
||||
document.querySelector(`#${target}`).scrollIntoView({
|
||||
|
||||
let targetPane = document.querySelector(`[data-id=${target}]`)
|
||||
if(!targetPane) return
|
||||
|
||||
targetPane.scrollIntoView({
|
||||
behavior: 'smooth'
|
||||
})
|
||||
Panes.switch(target)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
// nav buttons handler
|
||||
document.querySelector('#nav').onclick = function (e) {
|
||||
e.preventDefault()
|
||||
let target = e.target.getAttribute('data-target')
|
||||
if (target) {
|
||||
Panes.scrollTo(target)
|
||||
@@ -27,7 +34,7 @@ window.onload = function () {
|
||||
}
|
||||
|
||||
// index buttons handler
|
||||
document.querySelector('#index>.grid').onclick = function (e) {
|
||||
document.querySelector('.pane.index>.grid').onclick = function (e) {
|
||||
console.log(this, e.target)
|
||||
if (e.target.classList.contains('active')) {
|
||||
window.open(e.target.getAttribute('data-link'))
|
||||
@@ -50,40 +57,44 @@ window.onload = function () {
|
||||
// scroll handler
|
||||
document.querySelector('.wrapper').addEventListener('scroll', function (e) {
|
||||
let x = this.scrollTop / window.innerHeight,
|
||||
y = Math.floor(x + .5)
|
||||
y = Math.floor(x + .5),
|
||||
z = x % 1,
|
||||
v = 1 - z
|
||||
|
||||
clearTimeout(Panes.scrollTimeout)
|
||||
Panes.scrollTimeout = setTimeout(function () {
|
||||
Panes.scrollTo(document.querySelector('.panes').children[y].id)
|
||||
Panes.switch(document.querySelector('.panes').children[y].getAttribute('data-id'))
|
||||
if (z < .2 || v < .2)
|
||||
Panes.scrollTo(document.querySelector('.panes').children[y].getAttribute('data-id'))
|
||||
}, 200)
|
||||
|
||||
});
|
||||
|
||||
// window.onhashchange = e => {
|
||||
// e.preventDefault()
|
||||
// console.log(e, location.hash)
|
||||
// }
|
||||
|
||||
// hash check
|
||||
if (location.hash) {
|
||||
let target = location.hash.slice(1)
|
||||
if (!document.querySelector(`#${target}`)) return
|
||||
Panes.switch(target)
|
||||
document.querySelector(`#${target}`).scrollIntoView()
|
||||
window.scrollTo(0, 0) // prevent scroll jump
|
||||
let target = location.hash.slice(1) // get target pane
|
||||
Panes.scrollTo(target)
|
||||
|
||||
}
|
||||
|
||||
// initial typewriter animation
|
||||
document.querySelectorAll('.typein').forEach(typein => {
|
||||
var target = typein.getAttribute('data-content')
|
||||
function print(index) {
|
||||
typein.textContent += target[index]
|
||||
if (target[index + 1]) {
|
||||
|
||||
function print(index = 0) {
|
||||
typein.textContent += target[index] // add next char
|
||||
|
||||
if (target[index + 1]) { // if exists, shedule next char
|
||||
setTimeout(function () {
|
||||
print(index + 1)
|
||||
}, 75)
|
||||
}
|
||||
|
||||
}
|
||||
print(0)
|
||||
|
||||
print() // start animation
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
@@ -3,12 +3,22 @@
|
||||
--color-main: #f7b440;
|
||||
}
|
||||
|
||||
@keyframes fadein {
|
||||
from {
|
||||
transform: scale(50);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0px;
|
||||
font-family: Roboto;
|
||||
background-size: cover;
|
||||
color: #fefefe;
|
||||
background: #2c2c2b;
|
||||
background: hsl(60deg 1% 18%);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -80,6 +90,7 @@ body {
|
||||
margin: auto;
|
||||
box-sizing: border-box;
|
||||
border-top: 1px solid #fefefe33;
|
||||
scroll-margin: -1px;
|
||||
}
|
||||
|
||||
.pane:first-child {
|
||||
@@ -151,7 +162,7 @@ body {
|
||||
|
||||
/* about */
|
||||
|
||||
#about {
|
||||
.pane.about {
|
||||
text-align: center;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
@@ -231,7 +242,7 @@ body {
|
||||
|
||||
/* Index */
|
||||
|
||||
#index > .head {
|
||||
.pane.index > .head {
|
||||
font-family: 'Roboto Mono';
|
||||
margin-bottom: 2rem;
|
||||
height: 40%;
|
||||
|
||||
Reference in new issue
Block a user