Skip to content

Commit

Permalink
fix: Fixed homepage navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
HanzCEO committed Jan 19, 2024
1 parent 83f50b8 commit 98a732b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const NavBar = ({ color }) => {
<div className='navbar__mobile navbar__mobile__close'>
<X onClick={() => setClose('navbar__closed')} />
</div>
<a href="#profil">Profil</a>
<a href="#?content=profil">Profil</a>
<a href="https://itch.io/jams/hosted-by-hanzceo">Kompetisi</a>
<Link to="/gallery">Galeri</Link>

Expand Down
22 changes: 13 additions & 9 deletions src/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,26 @@ const Homepage = () => {
setProgress(Math.ceil(targetIndex/sectionCount*100) + '%');
}

function handleHashes() {
let hashval = window.location.hash.substr(1);
let searchArray = [...hashval.split('?'), ''][1].split('&').map(x => x.split('=', 2));
let search = {};
for (let s of searchArray) {
search[s[0]] = s[1];
}
console.log(search)
if (!search['content']) search['content'] = 'hero';
scrollTo(hashes.indexOf(search['content']));
}
let scrollTo = undefined;
function handleScrollInit({ scrollControl }) {
scrollTo = scrollControl.scrollTo.bind(scrollControl);

if (window.location.hash.substr(1)) {
let hashval = window.location.hash.substr(1);
if (hashval[0] == '/') {
redirect(hashval);
} else {
scrollTo(hashes.indexOf(window.location.hash.substr(1)));
}
handleHashes();
}

window.addEventListener('hashchange', () => {
scrollTo(hashes.indexOf(window.location.hash.substr(1)));
});
window.addEventListener('hashchange', handleHashes);
}

return (
Expand Down

0 comments on commit 98a732b

Please sign in to comment.