M
Size: a a a
M
M
DZ
M
AV
const breakpointPreMd = window.matchMedia('(max-width: 767px)') /* pre-md breakpoint */
;(function (breakpoint) {
try {
const $indexEducationProgramms = document.querySelector('.index-education-programms')
const $indexEducationProgrammsGrid = $indexEducationProgramms.querySelector('.index-education-programms__grid')
const $indexEducationProgrammsMore = $indexEducationProgramms.querySelector('.index-education-programms__more')
const $indexEducationProgrammsCards = $indexEducationProgrammsGrid.children
const countOfCards = $indexEducationProgrammsCards.length
const heightOfCard = $indexEducationProgrammsCards[0].getBoundingClientRect().height
const heightOfGap = parseInt(window.getComputedStyle($indexEducationProgrammsGrid).getPropertyValue('row-gap'))
function clickMoreHandler(event) {
event.target.classList.toggle('active')
setTimeout(() => {
if (event.target.classList.contains('active')) {
$indexEducationProgrammsGrid.style.height = `${
heightOfCard * countOfCards + heightOfGap * (countOfCards - 1)
}px`
event.target.textContent = 'Свернуть'
} else {
$indexEducationProgrammsGrid.style.height = `${heightOfCard * 4 + heightOfGap * 3}px`
event.target.textContent = 'Показать еще'
}
}, 0)
}
function breakpointChecker() {
if (breakpoint.matches) {
$indexEducationProgrammsGrid.style.height = `${heightOfCard * 4 + heightOfGap * 3}px`
$indexEducationProgrammsGrid.style.transition = 'height 0.3s'
$indexEducationProgrammsGrid.style.overflowY = 'hidden'
$indexEducationProgrammsMore.addEventListener('click', clickMoreHandler)
} else {
$indexEducationProgrammsMore.textContent = 'Показать еще'
$indexEducationProgrammsGrid.style.removeProperty('height')
$indexEducationProgrammsGrid.style.removeProperty('overflow-y')
setTimeout(function () {
$indexEducationProgrammsGrid.style.removeProperty('transition')
}, 300)
$indexEducationProgrammsMore.removeEventListener('click', clickMoreHandler)
}
}
window.addEventListener('resize', function () {
breakpointChecker()
})
breakpointChecker()
} catch (error) {
console.log(error)
}
})(breakpointPreMd)
Е
Е
DZ
DZ
M
M
DZ
M
DZ
M
M
M
DZ
M
VK