feat: remove header_link, adjust hero scroll to next, fix some html errors
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document
|
||||
.querySelectorAll('.hero-down-link')
|
||||
.forEach(link => link.addEventListener('click', scrollToNext));
|
||||
});
|
||||
|
||||
function scrollToNext(e) {
|
||||
e.preventDefault();
|
||||
const refEl = e.currentTarget;
|
||||
const isMobile = window.matchMedia('(max-width: 768px)').matches;
|
||||
|
||||
if (isMobile) {
|
||||
const target = document.getElementById('hero-text');
|
||||
if (!target) {
|
||||
console.warn('scrollToNext: no element with id="hero-text"');
|
||||
return;
|
||||
}
|
||||
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
|
||||
} else {
|
||||
const frames = Array.from(document.querySelectorAll('.frame'));
|
||||
const nextFrame = frames.find(frame =>
|
||||
refEl.compareDocumentPosition(frame) & Node.DOCUMENT_POSITION_FOLLOWING
|
||||
);
|
||||
|
||||
if (!nextFrame) {
|
||||
console.warn('scrollToNext: no .frame found after this link');
|
||||
return;
|
||||
}
|
||||
nextFrame.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user