25 lines
1006 B
JavaScript
25 lines
1006 B
JavaScript
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';
|
|
}
|
|
});
|
|
});
|