VoidVision commited on
Commit
d1abf67
·
verified ·
1 Parent(s): 67ebb22

add best effects and animations to the website

Browse files
Files changed (4) hide show
  1. components/particles.js +98 -0
  2. index.html +19 -11
  3. script.js +81 -6
  4. style.css +84 -9
components/particles.js ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class ParticleBackground extends HTMLElement {
2
+ connectedCallback() {
3
+ this.attachShadow({ mode: 'open' });
4
+ this.shadowRoot.innerHTML = `
5
+ <style>
6
+ :host {
7
+ position: absolute;
8
+ top: 0;
9
+ left: 0;
10
+ width: 100%;
11
+ height: 100%;
12
+ z-index: 0;
13
+ pointer-events: none;
14
+ overflow: hidden;
15
+ }
16
+ canvas {
17
+ position: absolute;
18
+ top: 0;
19
+ left: 0;
20
+ }
21
+ </style>
22
+ <canvas id="particles-canvas"></canvas>
23
+ `;
24
+
25
+ const canvas = this.shadowRoot.getElementById('particles-canvas');
26
+ const ctx = canvas.getContext('2d');
27
+ canvas.width = window.innerWidth;
28
+ canvas.height = window.innerHeight;
29
+
30
+ // Particle system
31
+ const particles = [];
32
+ const particleCount = Math.floor(window.innerWidth * window.innerHeight / 10000);
33
+ const colors = ['rgba(14, 165, 233, 0.6)', 'rgba(124, 58, 237, 0.6)', 'rgba(255, 255, 255, 0.8)'];
34
+
35
+ // Create particles
36
+ for (let i = 0; i < particleCount; i++) {
37
+ particles.push({
38
+ x: Math.random() * canvas.width,
39
+ y: Math.random() * canvas.height,
40
+ size: Math.random() * 3 + 1,
41
+ speedX: Math.random() * 1 - 0.5,
42
+ speedY: Math.random() * 1 - 0.5,
43
+ color: colors[Math.floor(Math.random() * colors.length)]
44
+ });
45
+ }
46
+
47
+ // Animation loop
48
+ const animate = () => {
49
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
50
+
51
+ // Update and draw particles
52
+ for (let i = 0; i < particles.length; i++) {
53
+ const p = particles[i];
54
+
55
+ // Update position
56
+ p.x += p.speedX;
57
+ p.y += p.speedY;
58
+
59
+ // Bounce off edges
60
+ if (p.x < 0 || p.x > canvas.width) p.speedX *= -1;
61
+ if (p.y < 0 || p.y > canvas.height) p.speedY *= -1;
62
+
63
+ // Draw particle
64
+ ctx.beginPath();
65
+ ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
66
+ ctx.fillStyle = p.color;
67
+ ctx.fill();
68
+
69
+ // Draw connections
70
+ for (let j = i + 1; j < particles.length; j++) {
71
+ const p2 = particles[j];
72
+ const distance = Math.sqrt(Math.pow(p.x - p2.x, 2) + Math.pow(p.y - p2.y, 2));
73
+
74
+ if (distance < 100) {
75
+ ctx.beginPath();
76
+ ctx.strokeStyle = `rgba(200, 200, 255, ${1 - distance/100})`;
77
+ ctx.lineWidth = 0.5;
78
+ ctx.moveTo(p.x, p.y);
79
+ ctx.lineTo(p2.x, p2.y);
80
+ ctx.stroke();
81
+ }
82
+ }
83
+ }
84
+
85
+ requestAnimationFrame(animate);
86
+ };
87
+
88
+ // Handle resize
89
+ window.addEventListener('resize', () => {
90
+ canvas.width = window.innerWidth;
91
+ canvas.height = window.innerHeight;
92
+ });
93
+
94
+ animate();
95
+ }
96
+ }
97
+
98
+ customElements.define('particle-background', ParticleBackground);
index.html CHANGED
@@ -44,16 +44,22 @@
44
  </script>
45
  </head>
46
  <body class="bg-gray-50 text-gray-900 font-sans antialiased">
 
47
  <custom-navbar></custom-navbar>
48
- <main>
49
  <!-- Hero Section -->
50
- <section class="relative h-screen flex items-center justify-center overflow-hidden">
51
- <div class="absolute inset-0 bg-gradient-to-br from-primary-500 to-secondary-600 opacity-90"></div>
52
  <div class="absolute inset-0 bg-[url('https://static.photos/abstract/1200x630/42')] bg-cover bg-center mix-blend-overlay"></div>
 
53
  <div class="relative z-10 text-center px-4 max-w-4xl mx-auto">
54
- <h1 class="text-5xl md:text-7xl font-bold text-white mb-6 animate-fadeIn">PixelPulse Gallery</h1>
55
- <p class="text-xl md:text-2xl text-white/90 mb-8 max-w-2xl mx-auto animate-fadeIn delay-100">Where digital brushstrokes meet infinite imagination</p>
56
- <a href="#gallery" class="inline-flex items-center px-8 py-3 bg-white text-primary-600 rounded-full font-semibold shadow-lg hover:bg-gray-100 transition-all duration-300 animate-bounce">
 
 
 
 
57
  Explore Artworks
58
  <i data-feather="arrow-down" class="ml-2"></i>
59
  </a>
@@ -73,9 +79,9 @@
73
 
74
  <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
75
  <!-- Artwork 1 -->
76
- <div class="group relative overflow-hidden rounded-xl shadow-xl hover:shadow-2xl transition-all duration-500">
77
- <img src="https://static.photos/abstract/640x360/1" alt="Digital Artwork" class="w-full h-64 object-cover transition-transform duration-500 group-hover:scale-110">
78
- <div class="absolute inset-0 bg-gradient-to-t from-black/70 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-end p-6">
79
  <div>
80
  <h3 class="text-xl font-bold text-white">Cosmic Dreams</h3>
81
  <p class="text-white/80">Digital Painting | 2023</p>
@@ -303,11 +309,13 @@
303
  </main>
304
 
305
  <custom-footer></custom-footer>
306
-
 
307
  <script src="components/navbar.js"></script>
308
  <script src="components/footer.js"></script>
 
309
  <script src="script.js"></script>
310
- <script>
311
  feather.replace();
312
  </script>
313
  <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
 
44
  </script>
45
  </head>
46
  <body class="bg-gray-50 text-gray-900 font-sans antialiased">
47
+ <particle-background></particle-background>
48
  <custom-navbar></custom-navbar>
49
+ <main>
50
  <!-- Hero Section -->
51
+ <section class="hero-section relative h-screen flex items-center justify-center overflow-hidden">
52
+ <div class="absolute inset-0 bg-gradient-to-br from-primary-500 to-secondary-600 opacity-90 animate-gradientBG"></div>
53
  <div class="absolute inset-0 bg-[url('https://static.photos/abstract/1200x630/42')] bg-cover bg-center mix-blend-overlay"></div>
54
+ <div class="absolute inset-0 bg-[url('https://static.photos/abstract/1200x630/43')] bg-cover bg-center mix-blend-overlay opacity-0 hover:opacity-100 transition-opacity duration-1000"></div>
55
  <div class="relative z-10 text-center px-4 max-w-4xl mx-auto">
56
+ <h1 class="text-5xl md:text-7xl font-bold text-white mb-6 text-reveal" data-animate="fadeIn">
57
+ PixelPulse Gallery
58
+ </h1>
59
+ <p class="text-xl md:text-2xl text-white/90 mb-8 max-w-2xl mx-auto" data-animate="fadeIn" data-delay="100">
60
+ Where digital brushstrokes meet infinite imagination
61
+ </p>
62
+ <a href="#gallery" class="inline-flex items-center px-8 py-3 bg-white text-primary-600 rounded-full font-semibold shadow-lg hover:bg-gray-100 transition-all duration-300 animate-bounce">
63
  Explore Artworks
64
  <i data-feather="arrow-down" class="ml-2"></i>
65
  </a>
 
79
 
80
  <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
81
  <!-- Artwork 1 -->
82
+ <div class="artwork-card group relative overflow-hidden rounded-xl shadow-xl hover:shadow-2xl transition-all duration-500 transform-style-preserve-3d">
83
+ <img src="https://static.photos/abstract/640x360/1" alt="Digital Artwork" class="w-full h-64 object-cover transition-transform duration-500 group-hover:scale-110" data-animate="fadeIn">
84
+ <div class="absolute inset-0 bg-gradient-to-t from-black/70 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex items-end p-6">
85
  <div>
86
  <h3 class="text-xl font-bold text-white">Cosmic Dreams</h3>
87
  <p class="text-white/80">Digital Painting | 2023</p>
 
309
  </main>
310
 
311
  <custom-footer></custom-footer>
312
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.4/gsap.min.js"></script>
313
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.4/ScrollTrigger.min.js"></script>
314
  <script src="components/navbar.js"></script>
315
  <script src="components/footer.js"></script>
316
+ <script src="components/particles.js"></script>
317
  <script src="script.js"></script>
318
+ <script>
319
  feather.replace();
320
  </script>
321
  <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
script.js CHANGED
@@ -36,20 +36,30 @@ document.addEventListener('DOMContentLoaded', function() {
36
  this.reset();
37
  });
38
  }
39
-
40
- // Intersection Observer for animations
41
  const animateOnScroll = () => {
42
- const elements = document.querySelectorAll('.scroll-animate');
43
 
44
  const observer = new IntersectionObserver((entries) => {
45
  entries.forEach(entry => {
46
  if (entry.isIntersecting) {
47
- entry.target.classList.add('animate-fadeIn');
48
- observer.unobserve(entry.target);
 
 
 
 
 
 
 
 
 
 
49
  }
50
  });
51
  }, {
52
- threshold: 0.1
 
53
  });
54
 
55
  elements.forEach(element => {
@@ -57,5 +67,70 @@ document.addEventListener('DOMContentLoaded', function() {
57
  });
58
  };
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  animateOnScroll();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  });
 
36
  this.reset();
37
  });
38
  }
39
+ // Enhanced Intersection Observer for animations
 
40
  const animateOnScroll = () => {
41
+ const elements = document.querySelectorAll('[data-animate]');
42
 
43
  const observer = new IntersectionObserver((entries) => {
44
  entries.forEach(entry => {
45
  if (entry.isIntersecting) {
46
+ const animationType = entry.target.getAttribute('data-animate');
47
+ const delay = entry.target.getAttribute('data-delay') || '0';
48
+
49
+ entry.target.style.setProperty('--delay', delay);
50
+ entry.target.classList.add(`animate-${animationType}`);
51
+
52
+ // Remove observer if not a repeating animation
53
+ if (!entry.target.hasAttribute('data-repeat')) {
54
+ observer.unobserve(entry.target);
55
+ }
56
+ } else if (entry.target.hasAttribute('data-repeat')) {
57
+ entry.target.classList.remove(`animate-${animationType}`);
58
  }
59
  });
60
  }, {
61
+ threshold: 0.1,
62
+ rootMargin: '-50px'
63
  });
64
 
65
  elements.forEach(element => {
 
67
  });
68
  };
69
 
70
+ // Parallax effect for hero background
71
+ const heroSection = document.querySelector('.hero-section');
72
+ if (heroSection) {
73
+ window.addEventListener('scroll', () => {
74
+ const scrollPosition = window.pageYOffset;
75
+ heroSection.style.backgroundPositionY = `${scrollPosition * 0.5}px`;
76
+ });
77
+ }
78
+
79
+ // Hover tilt effect for artwork cards
80
+ const artworkCards = document.querySelectorAll('.artwork-card');
81
+ artworkCards.forEach(card => {
82
+ card.addEventListener('mousemove', (e) => {
83
+ const xAxis = (window.innerWidth / 2 - e.pageX) / 25;
84
+ const yAxis = (window.innerHeight / 2 - e.pageY) / 25;
85
+ card.style.transform = `rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
86
+ });
87
+
88
+ card.addEventListener('mouseenter', () => {
89
+ card.style.transition = 'transform 0.1s ease';
90
+ });
91
+
92
+ card.addEventListener('mouseleave', () => {
93
+ card.style.transition = 'transform 0.5s ease';
94
+ card.style.transform = 'rotateY(0deg) rotateX(0deg)';
95
+ });
96
+ });
97
+
98
+ // Initialize animations
99
  animateOnScroll();
100
+
101
+ // Animate elements when they become visible
102
+ const animatedElements = document.querySelectorAll('[data-animate-on-visible]');
103
+ const visibilityObserver = new IntersectionObserver((entries) => {
104
+ entries.forEach(entry => {
105
+ if (entry.isIntersecting) {
106
+ entry.target.classList.add('visible');
107
+ }
108
+ });
109
+ }, { threshold: 0.1 });
110
+
111
+ animatedElements.forEach(element => {
112
+ visibilityObserver.observe(element);
113
+ });
114
+
115
+ // Text reveal animation
116
+ const textRevealElements = document.querySelectorAll('.text-reveal');
117
+ textRevealElements.forEach(element => {
118
+ const letters = element.textContent.split('');
119
+ element.innerHTML = letters.map(letter =>
120
+ `<span class="text-reveal-char">${letter}</span>`
121
+ ).join('');
122
+
123
+ gsap.from(element.querySelectorAll('.text-reveal-char'), {
124
+ y: '100%',
125
+ opacity: 0,
126
+ duration: 0.6,
127
+ ease: 'back.out(1.7)',
128
+ stagger: 0.03,
129
+ scrollTrigger: {
130
+ trigger: element,
131
+ start: 'top 80%',
132
+ toggleActions: 'play none none none'
133
+ }
134
+ });
135
+ });
136
  });
style.css CHANGED
@@ -1,28 +1,103 @@
 
1
  @keyframes fadeIn {
2
- from { opacity: 0; transform: translateY(20px); }
3
  to { opacity: 1; transform: translateY(0); }
4
  }
5
 
6
  @keyframes bounce {
7
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
8
- 40% { transform: translateY(-20px); }
9
- 60% { transform: translateY(-10px); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  }
11
 
12
  .animate-fadeIn {
13
- animation: fadeIn 1s ease-out forwards;
14
  }
15
 
16
- .delay-100 {
17
- animation-delay: 100ms;
18
  }
19
 
20
- .delay-200 {
21
- animation-delay: 200ms;
22
  }
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  .animate-bounce {
25
- animation: bounce 2s infinite;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
 
28
  /* Custom scrollbar */
 
1
+
2
  @keyframes fadeIn {
3
+ from { opacity: 0; transform: translateY(30px); }
4
  to { opacity: 1; transform: translateY(0); }
5
  }
6
 
7
  @keyframes bounce {
8
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
9
+ 40% { transform: translateY(-30px); }
10
+ 60% { transform: translateY(-15px); }
11
+ }
12
+
13
+ @keyframes float {
14
+ 0% { transform: translateY(0px); }
15
+ 50% { transform: translateY(-20px); }
16
+ 100% { transform: translateY(0px); }
17
+ }
18
+
19
+ @keyframes pulse {
20
+ 0% { transform: scale(1); }
21
+ 50% { transform: scale(1.05); }
22
+ 100% { transform: scale(1); }
23
+ }
24
+
25
+ @keyframes gradientBG {
26
+ 0% { background-position: 0% 50%; }
27
+ 50% { background-position: 100% 50%; }
28
+ 100% { background-position: 0% 50%; }
29
+ }
30
+
31
+ @keyframes slideInLeft {
32
+ from { opacity: 0; transform: translateX(-50px); }
33
+ to { opacity: 1; transform: translateX(0); }
34
+ }
35
+
36
+ @keyframes slideInRight {
37
+ from { opacity: 0; transform: translateX(50px); }
38
+ to { opacity: 1; transform: translateX(0); }
39
+ }
40
+
41
+ @keyframes rotate {
42
+ from { transform: rotate(0deg); }
43
+ to { transform: rotate(360deg); }
44
  }
45
 
46
  .animate-fadeIn {
47
+ animation: fadeIn 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
48
  }
49
 
50
+ .animate-float {
51
+ animation: float 6s ease-in-out infinite;
52
  }
53
 
54
+ .animate-pulse {
55
+ animation: pulse 3s ease infinite;
56
  }
57
 
58
+ .animate-gradientBG {
59
+ background: linear-gradient(270deg, #0ea5e9, #7c3aed, #0ea5e9);
60
+ background-size: 400% 400%;
61
+ animation: gradientBG 12s ease infinite;
62
+ }
63
+
64
+ .animate-slideInLeft {
65
+ animation: slideInLeft 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
66
+ }
67
+
68
+ .animate-slideInRight {
69
+ animation: slideInRight 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
70
+ }
71
+
72
+ .animate-rotate {
73
+ animation: rotate 20s linear infinite;
74
+ }
75
+
76
+ .delay-100 { animation-delay: 100ms; }
77
+ .delay-200 { animation-delay: 200ms; }
78
+ .delay-300 { animation-delay: 300ms; }
79
+ .delay-400 { animation-delay: 400ms; }
80
+ .delay-500 { animation-delay: 500ms; }
81
+
82
  .animate-bounce {
83
+ animation: bounce 2.5s infinite;
84
+ }
85
+ /* 3D Perspective */
86
+ .transform-style-preserve-3d {
87
+ transform-style: preserve-3d;
88
+ perspective: 1000px;
89
+ }
90
+
91
+ /* Text Reveal Effect */
92
+ .text-reveal {
93
+ overflow: hidden;
94
+ display: inline-block;
95
+ }
96
+
97
+ .text-reveal-char {
98
+ display: inline-block;
99
+ transform: translateY(100%);
100
+ opacity: 0;
101
  }
102
 
103
  /* Custom scrollbar */