Compare commits
2 Commits
615716d72e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
a607318eff
|
|||
|
99131cea6f
|
18
www/main.js
18
www/main.js
@ -18,9 +18,15 @@ const imaTexts = shuffle([
|
||||
'I\'m an $ice skater',
|
||||
'I\'m a $masochist',
|
||||
'I\'m a $professional alcoholic',
|
||||
'I\'m a $Vim addict'
|
||||
'I\'m a $Vim addict',
|
||||
'I\'m an $accidental UK shock collar provider',
|
||||
'I play $Beat Saber',
|
||||
'I play $VRChat',
|
||||
'I\'m a $Blender user'
|
||||
]);
|
||||
|
||||
var currentTab = null;
|
||||
|
||||
function shuffle(array) {
|
||||
return array
|
||||
.map(value => ({ value, sort: Maths.random() }))
|
||||
@ -38,6 +44,12 @@ function switchTab(tabID, playAnimation=true) {
|
||||
tabID = tabID.id.split('button-')[1];
|
||||
}
|
||||
|
||||
if (currentTab == tabID) { return; }
|
||||
|
||||
console.log(`Switching from ${currentTab} to ${tabID}...`);
|
||||
currentTab = tabID;
|
||||
location.hash = `#${tabID}`;
|
||||
|
||||
let tabTransitionTime = Number(getComputedStyle(document.body).getPropertyValue('--tab-transition-time').slice(0, -2));
|
||||
let tabs = document.getElementsByTagName('main')[0].children;
|
||||
let tab = document.getElementById(`tab-${tabID}`);
|
||||
@ -88,6 +100,10 @@ function switchTab(tabID, playAnimation=true) {
|
||||
button.classList.add('buttonHighlight');
|
||||
}
|
||||
|
||||
window.addEventListener('hashchange', (e) => {
|
||||
switchTab(location.hash.slice(1));
|
||||
});
|
||||
|
||||
window.addEventListener('load', (e) => {
|
||||
switchTab('home', false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user