Files
react-native/js/headerAnimation.js
T
Website Deployment Script 4c413e71a4 Deploy website
Deploy website version based on 861b420b257c82d8c0d993881f2794576f88fb7f
2019-08-05 09:30:53 +00:00

45 lines
1.0 KiB
JavaScript

document.addEventListener('DOMContentLoaded', () => {
const steps = ['full', 'mobile', 'desktop', 'laptop', 'mobile2', 'full2'];
const intervals = [1250, 1500, 1500, 1500, 1500, 1250];
let i = 0;
const timeouts = [];
const logo = document.querySelector('.LogoAnimation');
function animateStep() {
const prev = steps[i];
logo.classList.remove(prev);
i = (i + 1) % steps.length;
const current = steps[i];
const timeout = intervals[i];
logo.classList.add(current);
timeouts.push(setTimeout(animateStep, timeout));
}
timeouts.push(
setTimeout(() => {
logo.classList.remove('init');
animateStep();
}, 2000)
);
// https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
document.addEventListener(
'visibilitychange',
() => {
if (document.hidden) {
timeouts.forEach(timeout => {
clearTimeout(timeout);
});
// clear the timeouts array
timeouts.length = 0;
} else {
animateStep();
}
},
false
);
});