-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
47 lines (36 loc) · 1.37 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* ===( CODE AASHU )=== */
let isFirefox = typeof InstallTrigger !== 'undefined';
const words = "The Web Designer";
let ANGLE = 360;
const ANIMATION_DURATION = 4000;
const animation = () => {
ANGLE -= 1; // Incremento do ângulo
document.querySelectorAll(".spiral *").forEach((el, i) => {
const translateY = Math.sin(ANGLE * (Math.PI / 120)) * 100;
const scale = Math.cos(ANGLE * (Math.PI / 120)) * 0.5 + 0.5;
const offset = parseInt(el.dataset.offset);
const delay = i * (ANIMATION_DURATION / 16) - offset;
setTimeout(() => {
el.style.transform = `translateY(${translateY}px) scale(${scale})`;
}, delay);
});
requestAnimationFrame(animation);
};
const characters = words.split("").forEach((char, i) => {
const createElement = (offset) => {
const div = document.createElement("div");
div.innerText = char;
div.classList.add("character");
div.setAttribute("data-offset", offset);
div.style.animationDelay = `-${i * (ANIMATION_DURATION / 16) - offset}ms`
return div;
};
document.querySelector("#spiral").append(createElement(0));
document
.querySelector("#spiral2")
.append(createElement((isFirefox ? 1 : -1) * (ANIMATION_DURATION / 2)));
});
// @property CSS doesn't work in Firefox, so it must be animated using JavaScript.
if(isFirefox){
animation();
}