about, home changes
This commit is contained in:
@@ -1322,3 +1322,75 @@
|
||||
io.observe(media);
|
||||
io.observe(content);
|
||||
})();
|
||||
|
||||
// ===== CTA SECTIONS: reveal + ripple =====
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function initCtaSections() {
|
||||
var sections = Array.prototype.slice.call(
|
||||
document.querySelectorAll('.bc-cta, .cert-cta')
|
||||
);
|
||||
var bootcampInner = document.querySelector('.bc-cta__inner');
|
||||
var reduceMotion = window.matchMedia(
|
||||
'(prefers-reduced-motion: reduce)'
|
||||
).matches;
|
||||
|
||||
if (bootcampInner) {
|
||||
if (reduceMotion || !('IntersectionObserver' in window)) {
|
||||
bootcampInner.classList.add('is-reveal-visible');
|
||||
} else {
|
||||
bootcampInner.classList.add('is-reveal-pending');
|
||||
|
||||
var observer = new IntersectionObserver(function (entries) {
|
||||
entries.forEach(function (entry) {
|
||||
if (entry.isIntersecting) {
|
||||
entry.target.classList.remove('is-reveal-pending');
|
||||
entry.target.classList.add('is-reveal-visible');
|
||||
observer.unobserve(entry.target);
|
||||
}
|
||||
});
|
||||
}, { threshold: 0.2 });
|
||||
|
||||
observer.observe(bootcampInner);
|
||||
}
|
||||
}
|
||||
|
||||
if (reduceMotion || !sections.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
sections.forEach(function (section) {
|
||||
var buttons = Array.prototype.slice.call(
|
||||
section.querySelectorAll('.btn')
|
||||
);
|
||||
|
||||
buttons.forEach(function (button) {
|
||||
button.addEventListener('click', function (event) {
|
||||
var rect = button.getBoundingClientRect();
|
||||
var hasPoint = event.clientX > 0 || event.clientY > 0;
|
||||
var x = hasPoint ? event.clientX - rect.left : rect.width / 2;
|
||||
var y = hasPoint ? event.clientY - rect.top : rect.height / 2;
|
||||
|
||||
var ripple = document.createElement('span');
|
||||
ripple.className = 'btn__ripple';
|
||||
ripple.style.left = x + 'px';
|
||||
ripple.style.top = y + 'px';
|
||||
button.appendChild(ripple);
|
||||
|
||||
ripple.addEventListener('animationend', function () {
|
||||
if (ripple.parentNode) {
|
||||
ripple.parentNode.removeChild(ripple);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', initCtaSections);
|
||||
} else {
|
||||
initCtaSections();
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user