Repository navigation
Expand file tree
/
Copy pathanimations.js
More file actions
84 lines (76 loc) · 2.32 KB
/
Copy pathanimations.js
File metadata and controls
84 lines (76 loc) · 2.32 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// animations.js - Sistema completo de animações
gsap.registerPlugin(ScrollTrigger, ScrollToPlugin);
// Funções de Animação Reutilizáveis
function animateTextChars(selector, delay = 0, staggerAmount = 0.03) {
const el = document.querySelector(selector);
if (el) {
const text = el.innerText;
el.innerText = '';
text.split('').forEach(char => {
const span = document.createElement('span');
span.style.display = 'inline-block';
span.style.opacity = 0;
span.style.transform = 'translateY(20px) scale(0.8)';
span.innerText = char === ' ' ? '\u00A0' : char;
el.appendChild(span);
});
gsap.to(el.querySelectorAll('span'), {
opacity: 1,
y: 0,
scale: 1,
duration: 0.5,
stagger: staggerAmount,
ease: "back.out(1.7)",
delay: delay,
scrollTrigger: {
trigger: el,
start: "top 90%",
toggleActions: "play none none none",
}
});
}
}
// Animações Comuns a Todas as Páginas
function initCommonAnimations() {
// Logo inicial
gsap.from(".logo", {
duration: 1.2,
opacity: 0,
scale: 0.3,
rotation: -15,
ease: "elastic.out(1, 0.5)",
delay: 0.2
});
// Itens do menu
gsap.from(".menu-items a", {
duration: 0.6,
opacity: 0,
y: -30,
stagger: 0.1,
delay: 0.8,
ease: "back.out(1.4)"
});
}
// Inicializar animações quando o DOM estiver pronto
document.addEventListener("DOMContentLoaded", () => {
initCommonAnimations();
// Botão Voltar ao Topo
const backToTopButton = document.querySelector(".back-to-top");
if (backToTopButton) {
window.addEventListener("scroll", () => {
if (window.scrollY > 300) {
backToTopButton.classList.add("visible");
} else {
backToTopButton.classList.remove("visible");
}
});
backToTopButton.addEventListener("click", (e) => {
e.preventDefault();
gsap.to(window, {
duration: 1,
scrollTo: 0,
ease: "power2.inOut"
});
});
}
});