-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
28 lines (25 loc) · 891 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function textAnim() {
// テキストアニメーション
const animationTargetElements = document.querySelectorAll(".textAnimation");
var tindex = 1;
for (let i = 0; i < animationTargetElements.length; i++) {
const targetElement = animationTargetElements[i],
texts = targetElement.textContent,
textsArray = [];
targetElement.textContent = "";
for (let j = 0; j < texts.split("").length; j++) {
const t = texts.split("")[j]
if (t == " ") {
textsArray.push(" ");
} else if (tindex == texts.split("").length) {
textsArray.push('<span><span id="tAnmLast" style="animation-delay: ' + (j * .1) + 's;">' + t + '</span></span>')
} else {
textsArray.push('<span><span style="animation-delay: ' + (j * .1) + 's;">' + t + '</span></span>')
}
tindex += 1;
}
for (let k = 0; k < textsArray.length; k++) {
targetElement.innerHTML += textsArray[k];
}
}
}