81 lines
2.2 KiB
JavaScript
81 lines
2.2 KiB
JavaScript
function toggleMenu(el) {
|
|
let nav = document.querySelector('nav');
|
|
el.classList.toggle('open');
|
|
nav.classList.toggle('open');
|
|
}
|
|
|
|
function toggleAbout() {
|
|
let arrow = document.querySelector('#about-arrow');
|
|
let aboutContent = document.querySelector('#about-hidden');
|
|
aboutContent.classList.toggle('open');
|
|
arrow.classList.toggle('open');
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
let body = document.querySelector('body');
|
|
if (document.querySelector('.swiper')) {
|
|
body.style.overflowY = "hidden";
|
|
} else {
|
|
body.style.overflowY = "auto";
|
|
}
|
|
let swiperEl = document.querySelector('.swiper');
|
|
if (swiperEl) {
|
|
swiperEl.style.opacity = 1;
|
|
resizeVerticalImages();
|
|
}
|
|
initSwiper();
|
|
barba.init({
|
|
transitions: [{
|
|
name: 'opacity-transition',
|
|
leave(data) {
|
|
return gsap.to(data.current.container, {
|
|
opacity: 0
|
|
})
|
|
},
|
|
enter(data) {
|
|
return gsap.from(data.next.container, {
|
|
opacity: 0
|
|
})
|
|
}
|
|
}]
|
|
});
|
|
barba.hooks.before((data) => {
|
|
if (swiperEl) {
|
|
swiperEl.style.opacity = 0;
|
|
}
|
|
});
|
|
barba.hooks.after((data) => {
|
|
swiperEl = document.querySelector('.swiper');
|
|
if (swiperEl) {
|
|
if (document.querySelector('.swiper') && !document.querySelector('.swiper-initialized')) {
|
|
initSwiper();
|
|
body.style.overflowY = "hidden";
|
|
}
|
|
swiperEl.style.opacity = 1;
|
|
} else {
|
|
body.style.overflowY = "auto";
|
|
}
|
|
resizeVerticalImages();
|
|
});
|
|
})
|
|
|
|
function initSwiper() {
|
|
let swiper = new Swiper('.swiper', {
|
|
loop: true,
|
|
navigation: {
|
|
nextEl: '.swiper-button-next',
|
|
prevEl: '.swiper-button-prev',
|
|
},
|
|
});
|
|
}
|
|
|
|
function resizeVerticalImages() {
|
|
let verticalImages = document.querySelectorAll('.swiper-slide > img');
|
|
for (let img of verticalImages) {
|
|
console.log(img.clientHeight > img.clientWidth);
|
|
if (img.clientHeight > img.clientWidth) {
|
|
console.log("yes");
|
|
img.style.width = "50%";
|
|
}
|
|
}
|
|
} |