-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
84 lines (70 loc) · 3.07 KB
/
script.js
File metadata and controls
84 lines (70 loc) · 3.07 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
document.addEventListener('DOMContentLoaded', function() {
// Animate elements on scroll
const animateOnScroll = () => {
const elements = document.querySelectorAll('.feature-card, .panel-preview, .data-card');
elements.forEach(element => {
const elementPosition = element.getBoundingClientRect().top;
const screenPosition = window.innerHeight / 1.3;
if (elementPosition < screenPosition) {
element.style.opacity = '1';
element.style.transform = 'translateY(0)';
}
});
};
// Set initial state for animation
const featureCards = document.querySelectorAll('.feature-card');
const panelPreviews = document.querySelectorAll('.panel-preview');
const dataCards = document.querySelectorAll('.data-card');
featureCards.forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
});
panelPreviews.forEach(panel => {
panel.style.opacity = '0';
panel.style.transform = 'translateY(30px)';
panel.style.transition = 'opacity 0.8s ease, transform 0.8s ease';
});
dataCards.forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
});
// Run animation on load and scroll
animateOnScroll();
window.addEventListener('scroll', animateOnScroll);
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
if (targetId === '#') return;
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 100,
behavior: 'smooth'
});
}
});
});
// Add hover effect to buttons
const buttons = document.querySelectorAll('.btn');
buttons.forEach(button => {
button.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-3px)';
});
button.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
});
});
// Add parallax effect to header
const header = document.querySelector('.stellar-header');
window.addEventListener('scroll', function() {
const scrollPosition = window.pageYOffset;
header.style.backgroundPositionY = scrollPosition * 0.5 + 'px';
});
// Console greeting
console.log('%c🚀 Welcome to Cosmic Explorer!', 'font-size: 18px; color: #6c5ce7; font-weight: bold;');
console.log('%cExplore the universe with our interactive visualizations.', 'font-size: 14px; color: #00cec9;');
});