Highlight contact section when navigating to it.
This commit is contained in:
parent
8961510492
commit
d6115aa0bb
2 changed files with 58 additions and 2 deletions
|
|
@ -1,3 +1,24 @@
|
|||
const highlightSectionFromHash = () =>
|
||||
{
|
||||
const { hash } = window.location;
|
||||
|
||||
if (hash === '#section-contact')
|
||||
{
|
||||
const section = document.getElementById(hash.substring(1))?.parentElement;// .closest('section');
|
||||
|
||||
if (section)
|
||||
{
|
||||
setTimeout(() =>
|
||||
{
|
||||
section.classList.add('scrollto-highlight');
|
||||
setTimeout(() => section.classList.remove('scrollto-highlight'), 1000);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('hashchange', highlightSectionFromHash);
|
||||
|
||||
window.addEventListener('pageshow', () =>
|
||||
{
|
||||
/**
|
||||
|
|
@ -24,6 +45,8 @@ window.addEventListener('pageshow', () =>
|
|||
|
||||
refreshScrollLinkedPositioningEffect();
|
||||
window.addEventListener('scroll', refreshScrollLinkedPositioningEffect);
|
||||
|
||||
highlightSectionFromHash();
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue