-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
84 lines (73 loc) · 2.57 KB
/
script.js
File metadata and controls
84 lines (73 loc) · 2.57 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
// TRE Website Static - JavaScript
document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for navigation links
initSmoothScroll();
// Logo entrance animation
initLogoAnimation();
// Update footer year dynamically
updateFooterYear();
});
/**
* Initialize smooth scrolling for anchor links
*/
function initSmoothScroll() {
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
const headerOffset = 80; // Account for sticky header
const elementPosition = targetElement.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
}
});
});
}
/**
* Initialize logo entrance animation
*/
function initLogoAnimation() {
const heroLogo = document.querySelector('.hero-logo');
if (heroLogo) {
// Add staggered animation to logo elements
const logoBar = heroLogo.querySelector('.logo-bar');
const logoTriangle = heroLogo.querySelector('.logo-triangle');
const logoCircle = heroLogo.querySelector('.logo-circle');
if (logoBar) {
logoBar.style.opacity = '0';
setTimeout(() => {
logoBar.style.transition = 'opacity 0.8s ease-out';
logoBar.style.opacity = '1';
}, 1200);
}
if (logoTriangle) {
logoTriangle.style.opacity = '0';
setTimeout(() => {
logoTriangle.style.transition = 'opacity 0.8s ease-out';
logoTriangle.style.opacity = '1';
}, 100);
}
if (logoCircle) {
logoCircle.style.opacity = '0';
setTimeout(() => {
logoCircle.style.transition = 'opacity 0.8s ease-out';
logoCircle.style.opacity = '1';
}, 300);
}
}
}
/**
* Update footer year to current year
*/
function updateFooterYear() {
const footerText = document.querySelector('.footer-text');
if (footerText) {
const currentYear = new Date().getFullYear();
footerText.textContent = `© ${currentYear} Total Reality Engineering.`;
}
}