mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2024-11-01 14:10:29 +08:00
15 lines
520 B
JavaScript
15 lines
520 B
JavaScript
|
const duration = 0.8;
|
||
|
const delay = 0.3;
|
||
|
// eslint-disable-next-line no-undef
|
||
|
const revealText = document.querySelector('.reveal');
|
||
|
const letters = revealText.textContent.split('');
|
||
|
revealText.textContent = '';
|
||
|
const middle = letters.filter(e => e !== ' ').length / 2;
|
||
|
letters.forEach((letter, i) => {
|
||
|
// eslint-disable-next-line no-undef
|
||
|
const span = document.createElement('span');
|
||
|
span.textContent = letter;
|
||
|
span.style.animationDelay = `${delay + Math.abs(i - middle) * 0.1}s`;
|
||
|
revealText.append(span);
|
||
|
});
|