Day 5: JavaScript Challenge
Today we mess around with CSS Flexbox. Mozilla MDN explains this well, much better than I can be bothered to right now ;) here. This YouTube video is also really good at explaining it
JS code snippet below:
const panels = document.querySelectorAll('.panel');
function toggleOpen() {
this.classList.toggle('open');
}
function toggleActive(e) {
if (e.propertyName.includes('flex')) {
this.classList.toggle('open-active');
}
}
panels.forEach(panel => panel.addEventListener('click', toggleOpen));
panels.forEach(panel => panel.addEventListener('transitionend', toggleActive));