-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimation.js
52 lines (43 loc) · 1.49 KB
/
animation.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
48
49
50
51
52
$(document).ready(function () {
// Crie os pontos luminosos com ícones de formigas
createAntDots();
// Animação constante dos pontos
animateAntDots();
});
function createAntDots() {
// Crie um contêiner para os pontos
var dotsContainer = $("<div>").addClass("dots-container").appendTo(".div-container");
// Número de pontos
var numberOfDots = 100;
for (var i = 0; i < numberOfDots; i++) {
var dot = $("<div>").addClass("dot").html('<i class="fas fa-ant"></i>').appendTo(dotsContainer);
// Inicie cada ponto com posição e opacidade aleatórias
dot.css({
center: Math.random() * window.innerWidth * 0.9,
top: Math.random() * (window.innerHeight * 0.8),
opacity: Math.random(),
});
}
}
function animateAntDots() {
var allowedAreaX = window.innerWidth * 0.9;
var allowedAreaY = window.innerHeight * 0.8;
$(".dot").each(function (index) {
var dot = $(this);
// Animação de movimento aleatório
var randomX = Math.random() * allowedAreaX;
var randomY = Math.random() * allowedAreaY;
dot.animate(
{
left: randomX,
top: randomY,
opacity: Math.random(),
},
Math.random() * 10000 + 2000, // Tempo de animação entre 1 e 4 segundos
function () {
// Chama a animação novamente
animateAntDots();
}
);
});
}