index-main/assets/js/script.js

77 lines
1.8 KiB
JavaScript
Raw Normal View History

2026-01-06 13:57:45 +01:00
import { headerToggle, headerScrollVisibility } from './header.js';
import { copyLink } from './share.js';
2026-02-23 18:12:04 +01:00
import { backToTop } from './back-to-top.js';
2026-01-06 16:15:49 +01:00
import { themeToggle } from './themeToggle.js';
2026-01-08 16:09:58 +01:00
import { playVideo } from './hero-video.js';
2026-01-21 16:33:15 +01:00
import { initDropdowns } from './dropdown.js';
2026-01-29 20:57:17 +01:00
import { initSwipers } from './swipers.js';
2026-02-25 18:22:13 +01:00
import { initSliderBeforeAfter} from './sliderBeforeAfter.js';
import { navInvestigation } from './investigation.js';
import { progressBar, scrollBack} from './bottom-bar.js';
2026-02-25 16:07:14 +01:00
import { initSort } from './sort.js';
2026-01-06 13:57:45 +01:00
const responsiveMedium = 1080;
const responsiveSmall = 768;
2026-02-25 17:13:46 +01:00
const responsiveSmallX = 560;
2026-01-06 13:57:45 +01:00
2026-01-08 14:53:08 +01:00
window.onload = async function () {
2026-01-06 13:57:45 +01:00
console.log("SCRIPT LOADED");
2026-02-20 14:09:25 +01:00
2026-01-06 13:57:45 +01:00
headerToggle();
2026-01-06 16:15:49 +01:00
themeToggle();
2026-02-23 18:12:04 +01:00
backToTop();
2026-01-25 19:40:55 +01:00
2026-02-25 18:22:13 +01:00
initSliderBeforeAfter();
2026-01-25 19:40:55 +01:00
copyLink();
2026-01-08 16:09:58 +01:00
playVideo();
2026-02-25 17:13:46 +01:00
initDropdowns(responsiveSmall, responsiveSmallX);
2026-01-30 12:27:44 +01:00
initSwipers();
2026-02-09 14:45:33 +01:00
2026-02-23 14:02:26 +01:00
progressBar();
2026-02-25 18:22:13 +01:00
2026-02-23 14:02:26 +01:00
scrollBack();
navInvestigation();
2026-02-09 14:45:33 +01:00
2026-02-26 15:36:51 +01:00
var elems = document.querySelectorAll('.grid-masonry');
var msnries = [];
2026-02-09 14:45:33 +01:00
function initMasonry() {
2026-02-26 15:36:51 +01:00
if (!elems.length) return;
2026-02-09 14:45:33 +01:00
if (window.innerWidth >= responsiveSmall) {
2026-02-26 15:36:51 +01:00
elems.forEach(function(elem, i) {
if (!msnries[i]) {
msnries[i] = new Masonry(elem, {
itemSelector: '.card--block:not(.is-sort-hidden)',
columnWidth: '.grid-sizer',
percentPosition: true,
gutter: 26
});
}
});
2026-02-09 14:45:33 +01:00
} else {
2026-02-26 15:36:51 +01:00
msnries.forEach(function(msnry, i) {
if (msnry) {
msnry.destroy();
msnries[i] = null;
}
});
2026-02-09 14:45:33 +01:00
}
}
initMasonry();
window.addEventListener('resize', initMasonry);
2026-02-25 16:07:14 +01:00
initSort(() => {
2026-02-26 15:36:51 +01:00
msnries.forEach(function(msnry) {
if (msnry) {
msnry.reloadItems();
msnry.layout();
}
});
2026-02-25 16:07:14 +01:00
});
2026-02-09 14:45:33 +01:00
2026-01-06 13:57:45 +01:00
}