сделал how js для пк

This commit is contained in:
Kirill Pet
2024-12-18 23:25:47 +03:00
parent 8ec1dd88d6
commit 96948651b2
3 changed files with 114 additions and 78 deletions

View File

@@ -43,3 +43,32 @@ const reviewsSwiper = new Swiper('.reviews-swiper', {
})
// gymSwiper.destroy();
// how
function howPc() {
let itemButtons = document.querySelectorAll('.how-control__item'),
itemBlocks = document.querySelectorAll('.how-content__item-block');
itemButtons.forEach((button, index) => {
let block = itemBlocks[index];
button.onclick = function () {
let activeContent = document.querySelector('.how__content').querySelector('.active'),
activeButton = document.querySelector('.how__control').querySelector('.active');
activeContent.style.height = '0px';
activeContent.classList.remove('active');
activeButton.classList.remove('active');
setTimeout(() => {
let newHeight = block.querySelector('.how-content__item').offsetHeight + 'px';
block.style.height = newHeight;
block.classList.add('active');
button.classList.add('active');
}, 300);
}
})
}
howPc();