Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
(function() { | (function() { | ||
function initComponents() { | |||
// Аккордеоны | |||
document.querySelectorAll('.accordion-header').forEach(function(header) { | |||
header.addEventListener('click', function() { | |||
var content = this.nextElementSibling; | |||
var isActive = content.classList.contains('active'); | |||
}; | |||
document.querySelectorAll('.accordion-content').forEach(function(c) { | |||
c.classList.remove('active'); | |||
}); | |||
if (!isActive) { | |||
content.classList.add('active'); | |||
header.classList.add('active'); | |||
} | |||
}); | |||
}); | |||
// Параллакс эффекты | |||
window.addEventListener('mousemove', function(e) { | |||
var x = (e.clientX / window.innerWidth - 0.5) * 20; | |||
var y = (e.clientY / window.innerHeight - 0.5) * 20; | |||
document.querySelector('.title-container').style.transform = | |||
'translate(' + x + 'px, ' + y + 'px)'; | |||
}); | |||
} | |||
} | |||
} | |||
if (document.readyState === 'complete') { | if (document.readyState === 'complete') { | ||
initComponents(); | |||
} else { | } else { | ||
window.addEventListener('load', | window.addEventListener('load', initComponents); | ||
} | } | ||
})(); | })(); | ||
Версия от 21:21, 23 февраля 2025
(function() {
function initComponents() {
// Аккордеоны
document.querySelectorAll('.accordion-header').forEach(function(header) {
header.addEventListener('click', function() {
var content = this.nextElementSibling;
var isActive = content.classList.contains('active');
document.querySelectorAll('.accordion-content').forEach(function(c) {
c.classList.remove('active');
});
if (!isActive) {
content.classList.add('active');
header.classList.add('active');
}
});
});
// Параллакс эффекты
window.addEventListener('mousemove', function(e) {
var x = (e.clientX / window.innerWidth - 0.5) * 20;
var y = (e.clientY / window.innerHeight - 0.5) * 20;
document.querySelector('.title-container').style.transform =
'translate(' + x + 'px, ' + y + 'px)';
});
}
if (document.readyState === 'complete') {
initComponents();
} else {
window.addEventListener('load', initComponents);
}
})();