From 15abe10d23bafadd768c853ed99f3a610393f814 Mon Sep 17 00:00:00 2001 From: abhiramtx <7253115-abhiramtx@users.noreply.replit.com> Date: Sat, 8 Nov 2025 23:03:42 +0000 Subject: [PATCH] Add animated stars that fade in and out to sections without background images Implements a new JavaScript function `initStars` that dynamically creates and appends circular star elements to sections with the class `.home-info`. These stars have random sizes, positions, fade animations, and durations, controlled by CSS and keyframes defined in `static/css/styles.css`. The `initStars` function is called on page load via `initPageLoadAnimation`. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 5e584ab0-c340-4432-97ef-1972582b60e9 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: e42678c3-4b34-4047-bd6d-316f729459e1 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/d0a1d46d-d203-4308-bc6a-312ac7c0243b/5e584ab0-c340-4432-97ef-1972582b60e9/vuYxJMM --- static/css/styles.css | 37 +++++++++++++++++++++++++++++++++++++ static/js/scripts.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/static/css/styles.css b/static/css/styles.css index f8cdc88..109496d 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -307,6 +307,43 @@ hr { margin: 40px auto 64px auto; padding-bottom: 64px; color: var(--white); + position: relative; +} + +.home-info::before { + content: ''; + position: absolute; + top: 0; + left: -5%; + width: 110%; + height: 100%; + pointer-events: none; + z-index: 0; +} + +.home-info > * { + position: relative; + z-index: 1; +} + +.star { + position: absolute; + border-radius: 50%; + background: rgba(255, 255, 255, 0.6); + pointer-events: none; + animation: starFade var(--duration) ease-in-out infinite; + animation-delay: var(--delay); +} + +@keyframes starFade { + 0%, 100% { + opacity: 0; + transform: scale(0); + } + 50% { + opacity: 1; + transform: scale(1); + } } .team-info { diff --git a/static/js/scripts.js b/static/js/scripts.js index 16cae60..84440d1 100644 --- a/static/js/scripts.js +++ b/static/js/scripts.js @@ -96,6 +96,7 @@ document.addEventListener('DOMContentLoaded', function() { initPageLoadAnimation(); initCustomCursor(); initScrollIndicator(); + initStars(); }); function initParallaxEffects() { @@ -389,3 +390,33 @@ function initScrollIndicator() { indicator.style.width = progress + '%'; }); } + +function initStars() { + const sections = document.querySelectorAll('.home-info'); + + sections.forEach(section => { + const sectionHeight = section.offsetHeight; + const sectionWidth = section.offsetWidth; + const numStars = Math.floor((sectionWidth * sectionHeight) / 15000); + + for (let i = 0; i < numStars; i++) { + const star = document.createElement('div'); + star.className = 'star'; + + const size = Math.random() * 3 + 1; + const x = Math.random() * 100; + const y = Math.random() * 100; + const duration = Math.random() * 3 + 2; + const delay = Math.random() * 3; + + star.style.width = size + 'px'; + star.style.height = size + 'px'; + star.style.left = x + '%'; + star.style.top = y + '%'; + star.style.setProperty('--duration', duration + 's'); + star.style.setProperty('--delay', delay + 's'); + + section.appendChild(star); + } + }); +}