Initial commit
This commit is contained in:
24
js/quickLinks.js
Normal file
24
js/quickLinks.js
Normal file
@@ -0,0 +1,24 @@
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var quickLinks = document.querySelector('.quick-links');
|
||||
if (!quickLinks) return;
|
||||
|
||||
// Last section: keyword cloud if present, otherwise last swiper section
|
||||
var lastSection = document.querySelector('.keyword-cloud');
|
||||
if (!lastSection) {
|
||||
var swiperSections = document.querySelectorAll('.swiper-section');
|
||||
lastSection = swiperSections[swiperSections.length - 1] || null;
|
||||
}
|
||||
if (!lastSection) return;
|
||||
|
||||
var initialTop = quickLinks.getBoundingClientRect().top + window.scrollY;
|
||||
var quickLinksHeight = quickLinks.offsetHeight;
|
||||
|
||||
window.addEventListener('scroll', function () {
|
||||
var sectionBottom = lastSection.getBoundingClientRect().bottom;
|
||||
if (initialTop - sectionBottom > 0) {
|
||||
quickLinks.style.top = (initialTop - (initialTop - sectionBottom) - quickLinksHeight) + 'px';
|
||||
} else {
|
||||
quickLinks.style.top = initialTop + 'px';
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user