It sounds like the primary issue is that your JavaScript isn't executing correctly, which is likely causing the elements that should become visible through animations to remain hidden (opacity: 0). A common culprit for such behavior is the use of the integrity and crossorigin attributes in your <script> tags. If the integrity hashes do not match the actual files, the browser will block these scripts from loading, preventing your JavaScript from running.
To resolve this, you can remove the integrity and crossorigin attributes from your <script> tags. Alternatively, you can ensure that the integrity hashes match the actual scripts being loaded. For simplicity and to ensure that scripts load correctly, I'll provide a revised version of your HTML without these attributes.
Additionally, to enhance maintainability and readability, it's a good practice to separate your CSS and JavaScript into their own files. However, for the sake of simplicity, I'll keep everything in a single HTML file but ensure that the scripts load correctly.
Here's the corrected and refactored version of your HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Julia Murphy Tribute</title>
<meta name="description" content="A heartfelt tribute website celebrating Julia Murphy's artistic journey and our cherished memories together.">
<!-- Preload Images -->
<link rel="preload" as="image" href="https://source.unsplash.com/2560x1440/?romantic">
<link rel="preload" as="image" href="https://source.unsplash.com/600x400/?couple,love">
<link rel="preload" as="image" href="https://source.unsplash.com/600x400/?sunset,love">
<link rel="preload" as="image" href="https://source.unsplash.com/600x400/?mountains,love">
<link rel="preload" as="image" href="https://source.unsplash.com/600x400/?graffiti,hiphop">
<!-- Styles -->
<style>
:root {
--primary-color: #ff6b6b;
--background-color: #1e293b;
--text-color: #f8fafc;
--secondary-text-color: #d1d5db;
--notification-background: #34d399;
--notification-text-color: #fff;
}
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
scroll-behavior: smooth;
background: var(--background-color);
color: var(--text-color);
overflow-x: hidden;
}
header {
position: fixed;
top: 0;
width: 100%;
background: rgba(30, 41, 59, 0.95);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
z-index: 1000;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 2rem;
}
nav .logo {
font-size: 1.8rem;
font-weight: bold;
color: var(--primary-color);
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}
nav ul {
list-style: none;
display: flex;
gap: 1.5rem;
}
nav ul li a {
text-decoration: none;
color: var(--text-color);
font-weight: 500;
position: relative;
}
nav ul li a::after {
content: '';
position: absolute;
left: 0;
bottom: -5px;
width: 0;
height: 2px;
background: var(--primary-color);
transition: width 0.3s;
}
nav ul li a:hover::after {
width: 100%;
}
.hamburger {
display: none;
flex-direction: column;
cursor: pointer;
}
.hamburger div {
width: 25px;
height: 3px;
background: var(--text-color);
margin: 4px 0;
transition: all 0.3s;
}
@media (max-width: 600px) {
nav ul {
display: none;
flex-direction: column;
background: rgba(30, 41, 59, 0.95);
position: absolute;
top: 60px;
right: 20px;
border-radius: 8px;
padding: 1rem;
}
nav ul.active {
display: flex;
}
.hamburger {
display: flex;
}
}
section {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
position: relative;
padding: 4rem 2rem;
}
#home {
background: url('https://source.unsplash.com/2560x1440/?romantic') no-repeat center center/cover;
flex-direction: column;
color: #fff;
text-align: center;
position: relative;
}
#home::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(30, 41, 59, 0.6);
}
#home .content {
position: relative;
z-index: 1;
}
#home h1 {
font-size: 4rem;
margin-bottom: 1rem;
text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.7);
opacity: 0;
}
#home p {
font-size: 1.5rem;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
opacity: 0;
}
.content {
max-width: 900px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
section h2 {
font-size: 2.5rem;
margin-bottom: 1rem;
color: var(--primary-color);
opacity: 0;
}
section p {
font-size: 1.2rem;
color: var(--secondary-text-color);
opacity: 0;
}
#memories .memory,
#gallery .photo,
#squares .square {
position: relative;
overflow: hidden;
border-radius: 15px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
opacity: 0;
}
#memories .memory img,
#gallery .photo img,
#squares .square img {
width: 100%;
height: auto;
transition: transform 0.5s;
}
#memories .memory:hover img,
#gallery .photo:hover img,
#squares .square:hover img {
transform: scale(1.05);
}
#gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
gap: 1.5rem;
margin-top: 2rem;
}
#squares {
background: var(--background-color);
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
position: relative;
padding: 4rem 2rem;
}
#squares::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(30, 41, 59, 0.8);
}
#squares .content {
position: relative;
z-index: 1;
}
#squares .interaction {
display: flex;
flex-wrap: wrap;
gap: 1rem;
justify-content: center;
opacity: 0;
}
#squares .square {
width: 120px;
height: 120px;
background: var(--primary-color);
display: flex;
align-items: center;
justify-content: center;
font-size: 2.5rem;
color: #fff;
cursor: pointer;
transition: transform 0.3s, background 0.3s;
border-radius: 10px;
outline: none;
}
#squares .square:hover,
#squares .square:focus {
transform: rotate(20deg) scale(1.2);
background: #ff4757;
}
#graffiti {
background: url('https://source.unsplash.com/2560x1440/?graffiti') no-repeat center center/cover;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
color: #fff;
text-align: center;
position: relative;
padding: 4rem 2rem;
}
#graffiti::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(30, 41, 59, 0.6);
}
#graffiti .content {
position: relative;
z-index: 1;
}
#graffiti .wall {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
gap: 1.5rem;
margin-top: 2rem;
opacity: 0;
}
#graffiti .wall img {
width: 100%;
height: auto;
border: 3px solid var(--primary-color);
transition: transform 0.3s;
border-radius: 10px;
cursor: pointer;
}
#graffiti .wall img:hover,
#graffiti .wall img:focus {
transform: scale(1.1);
}
footer {
background: var(--background-color);
color: var(--text-color);
text-align: center;
padding: 1rem;
position: relative;
z-index: 1;
}
canvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 0;
opacity: 0.3;
}
#notification {
position: fixed;
bottom: 20px;
right: 20px;
background: var(--notification-background);
color: var(--notification-text-color);
padding: 1rem 1.5rem;
border-radius: 5px;
box-shadow: 0 2px 10px rgba(0,0,0,0.3);
z-index: 1002;
display: none;
opacity: 0;
transition: opacity 0.5s;
}
.show {
display: block;
opacity: 1;
}
.lightbox-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.8);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
z-index: 1001;
opacity: 0;
transition: opacity 0.5s;
}
.lightbox-overlay img {
max-width: 90%;
max-height: 90%;
border-radius: 10px;
}
</style>
</head>
<body>
<!-- Notification -->
<div id="notification"></div>
<!-- Header -->
<header>
<nav>
<div class="logo">Julia Murphy Tribute</div>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#memories">Memories</a></li>
<li><a href="#gallery">Gallery</a></li>
<li><a href="#squares">The Squares</a></li>
<li><a href="#graffiti">Graffiti Wall</a></li>
</ul>
<div class="hamburger" aria-label="Toggle navigation" tabindex="0">
<div></div>
<div></div>
<div></div>
</div>
</nav>
</header>
<!-- Background Canvas -->
<canvas id="backgroundCanvas"></canvas>
<!-- Home Section -->
<section id="home">
<div class="content">
<h1>Happy Anniversary, Julia!</h1>
<p>Celebrating our love and the beautiful moments we've shared.</p>
</div>
</section>
<!-- Memories Section -->
<section id="memories">
<div class="content">
<h2>Our Memories</h2>
<p>Relive the cherished moments that define our journey together.</p>
<div style="display:flex;flex-wrap:wrap;gap:1.5rem;margin-top:2rem;justify-content:center">
<div class="memory" style="width:600px;position:relative">
<img src="https://source.unsplash.com/600x400/?couple,love" alt="Julia and you walking hand in hand on your first date" loading="lazy" srcset="https://source.unsplash.com/600x400/?couple,love 600w,https://source.unsplash.com/1200x800/?couple,love 1200w,https://source.unsplash.com/1800x1200/?couple,love 1800w" sizes="(max-width:600px) 100vw,600px">
<div style="position:absolute;bottom:20px;left:20px;color:#fff;font-size:1.2rem;text-shadow:1px 1px 3px rgba(0,0,0,0.7)">Our First Date</div>
</div>
<div class="memory" style="width:600px;position:relative">
<img src="https://source.unsplash.com/600x400/?sunset,love" alt="Sunset together on the beach" loading="lazy" srcset="https://source.unsplash.com/600x400/?sunset,love 600w,https://source.unsplash.com/1200x800/?sunset,love 1200w,https://source.unsplash.com/1800x1200/?sunset,love 1800w" sizes="(max-width:600px) 100vw,600px">
<div style="position:absolute;bottom:20px;left:20px;color:#fff;font-size:1.2rem;text-shadow:1px 1px 3px rgba(0,0,0,0.7)">Sunset at the Beach</div>
</div>
<div class="memory" style="width:600px;position:relative">
<img src="https://source.unsplash.com/600x400/?mountains,love" alt="Couple hiking in the mountains" loading="lazy" srcset="https://source.unsplash.com/600x400/?mountains,love 600w,https://source.unsplash.com/1200x800/?mountains,love 1200w,https://source.unsplash.com/1800x1200/?mountains,love 1800w" sizes="(max-width:600px) 100vw,600px">
<div style="position:absolute;bottom:20px;left:20px;color:#fff;font-size:1.2rem;text-shadow:1px 1px 3px rgba(0,0,0,0.7)">Mountain Adventure</div>
</div>
</div>
</div>
</section>
<!-- Gallery Section -->
<section id="gallery">
<div class="content">
<h2>Photo Gallery</h2>
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(350px,1fr));gap:1.5rem;margin-top:2rem">
<div class="photo">
<img src="https://source.unsplash.com/800x600/?love,flowers" alt="Blooming flowers symbolizing love" loading="lazy" srcset="https://source.unsplash.com/800x600/?love,flowers 800w,https://source.unsplash.com/1600x1200/?love,flowers 1600w,https://source.unsplash.com/2400x1800/?love,flowers 2400w" sizes="(max-width:600px) 100vw,800px">
</div>
<div class="photo">
<img src="https://source.unsplash.com/800x600/?romantic,night" alt="Romantic night under the stars" loading="lazy" srcset="https://source.unsplash.com/800x600/?romantic,night 800w,https://source.unsplash.com/1600x1200/?romantic,night 1600w,https://source.unsplash.com/2400x1800/?romantic,night 2400w" sizes="(max-width:600px) 100vw,800px">
</div>
<div class="photo">
<img src="https://source.unsplash.com/800x600/?couple,dancing" alt="Couple dancing gracefully" loading="lazy" srcset="https://source.unsplash.com/800x600/?couple,dancing 800w,https://source.unsplash.com/1600x1200/?couple,dancing 1600w,https://source.unsplash.com/2400x1800/?couple,dancing 2400w" sizes="(max-width:600px) 100vw,800px">
</div>
<div class="photo">
<img src="https://source.unsplash.com/800x600/?kissing,love" alt="Intimate kiss between lovers" loading="lazy" srcset="https://source.unsplash.com/800x600/?kissing,love 800w,https://source.unsplash.com/1600x1200/?kissing,love 1600w,https://source.unsplash.com/2400x1800/?kissing,love 2400w" sizes="(max-width:600px) 100vw,800px">
</div>
<div class="photo">
<img src="https://source.unsplash.com/800x600/?couple,walk" alt="Couple walking in the park" loading="lazy" srcset="https://source.unsplash.com/800x600/?couple,walk 800w,https://source.unsplash.com/1600x1200/?couple,walk 1600w,https://source.unsplash.com/2400x1800/?couple,walk 2400w" sizes="(max-width:600px) 100vw,800px">
</div>
<div class="photo">
<img src="https://source.unsplash.com/800x600/?couple,coffee" alt="Couple enjoying coffee together" loading="lazy" srcset="https://source.unsplash.com/800x600/?couple,coffee 800w,https://source.unsplash.com/1600x1200/?couple,coffee 1600w,https://source.unsplash.com/2400x1800/?couple,coffee 2400w" sizes="(max-width:600px) 100vw,800px">
</div>
</div>
</div>
</section>
<!-- Squares Section -->
<section id="squares">
<div class="content">
<h2>The Squares</h2>
<p>Meet the Squares, our little anxious stick-figure friends who sometimes feel self-conscious. But with a little love and reassurance, they realize they're cherished and loved by everyone around them.</p>
<div class="interaction">
<div class="square" tabindex="0" aria-label="Square 1: Always anxious. Press or click to reassure.">🟥</div>
<div class="square" tabindex="0" aria-label="Square 2: Feels self-conscious. Press or click to encourage.">🟥</div>
<div class="square" tabindex="0" aria-label="Square 3: Doubts itself. Press or click to remind them they're loved.">🟥</div>
<div class="square" tabindex="0" aria-label="Square 4: Worried square. Press or click to comfort.">🟥</div>
<div class="square" tabindex="0" aria-label="Square 5: Shy square. Press or click to uplift.">🟥</div>
</div>
</div>
</section>
<!-- Graffiti Section -->
<section id="graffiti">
<div class="content">
<h2>Graffiti Wall</h2>
<p>Julia's passion for graffiti, under the name Blaze, with her crew USK. A tribute to the vibrant art and the creative spirit that lights up the streets.</p>
<div class="wall">
<img src="https://source.unsplash.com/1200x800/?graffiti,hiphop" alt="Blaze's graffiti art" loading="lazy" tabindex="0" srcset="https://source.unsplash.com/1200x800/?graffiti,hiphop 1200w,https://source.unsplash.com/2400x1600/?graffiti,hiphop 2400w,https://source.unsplash.com/3600x2400/?graffiti,hiphop 3600w" sizes="(max-width:600px) 100vw,1200px">
<img src="https://source.unsplash.com/1200x800/?graffiti,street" alt="USK crew tagging the wall" loading="lazy" tabindex="0" srcset="https://source.unsplash.com/1200x800/?graffiti,street 1200w,https://source.unsplash.com/2400x1600/?graffiti,street 2400w,https://source.unsplash.com/3600x2400/?graffiti,street 3600w" sizes="(max-width:600px) 100vw,1200px">
<img src="https://source.unsplash.com/1200x800/?graffiti,art" alt="Colorful street art by Blaze" loading="lazy" tabindex="0" srcset="https://source.unsplash.com/1200x800/?graffiti,art 1200w,https://source.unsplash.com/2400x1600/?graffiti,art 2400w,https://source.unsplash.com/3600x2400/?graffiti,art 3600w" sizes="(max-width:600px) 100vw,1200px">
<img src="https://source.unsplash.com/1200x800/?graffiti,urban" alt="Urban graffiti design" loading="lazy" tabindex="0" srcset="https://source.unsplash.com/1200x800/?graffiti,urban 1200w,https://source.unsplash.com/2400x1600/?graffiti,urban 2400w,https://source.unsplash.com/3600x2400/?graffiti,urban 3600w" sizes="(max-width:600px) 100vw,1200px">
<img src="https://source.unsplash.com/1200x800/?graffiti,design" alt="Creative graffiti mural" loading="lazy" tabindex="0" srcset="https://source.unsplash.com/1200x800/?graffiti,design 1200w,https://source.unsplash.com/2400x1600/?graffiti,design 2400w,https://source.unsplash.com/3600x2400/?graffiti,design 3600w" sizes="(max-width:600px) 100vw,1200px">
<img src="https://source.unsplash.com/1200x800/?graffiti,abstract" alt="Abstract graffiti art" loading="lazy" tabindex="0" srcset="https://source.unsplash.com/1200x800/?graffiti,abstract 1200w,https://source.unsplash.com/2400x1600/?graffiti,abstract 2400w,https://source.unsplash.com/3600x2400/?graffiti,abstract 3600w" sizes="(max-width:600px) 100vw,1200px">
</div>
</div>
</section>
<!-- Footer -->
<footer>
<p>© 2024 Julia Murphy Tribute. All rights reserved.</p>
</footer>
<!-- Scripts -->
<!-- Removed integrity and crossorigin attributes -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.5/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.5/ScrollTrigger.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
// Hamburger Menu Toggle
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('nav ul');
hamburger.addEventListener('click', toggleHamburgerMenu);
hamburger.addEventListener('keypress', e => {
if (e.key === 'Enter') toggleHamburgerMenu();
});
function toggleHamburgerMenu() {
navLinks.classList.toggle('active');
hamburger.classList.toggle('active');
}
// Three.js Particle Background
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer({ canvas: document.getElementById('backgroundCanvas'), alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
camera.position.z = 5;
const geometry = new THREE.BufferGeometry();
const vertices = [];
for (let i = 0; i < 2000; i++) {
const x = (Math.random() - 0.5) * 200;
const y = (Math.random() - 0.5) * 200;
const z = (Math.random() - 0.5) * 200;
vertices.push(x, y, z);
}
geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
const material = new THREE.PointsMaterial({ color: 0xffffff, size: 0.5 });
const particles = new THREE.Points(geometry, material);
scene.add(particles);
function animateParticles() {
requestAnimationFrame(animateParticles);
particles.rotation.y += 0.0005;
renderer.render(scene, camera);
}
animateParticles();
// GSAP Animations
gsap.registerPlugin(ScrollTrigger);
// Home Section Animations
gsap.from("#home h1", {
y: 50,
opacity: 0,
duration: 1,
ease: "power2.out",
scrollTrigger: {
trigger: "#home",
start: "top 80%"
}
});
gsap.from("#home p", {
y: 50,
opacity: 0,
duration: 1,
delay: 0.3,
ease: "power2.out",
scrollTrigger: {
trigger: "#home",
start: "top 80%"
}
});
// Memories Section Animations
gsap.from("#memories h2", {
y: 50,
opacity: 0,
duration: 1,
scrollTrigger: {
trigger: "#memories",
start: "top 80%"
}
});
gsap.from("#memories p", {
y: 50,
opacity: 0,
duration: 1,
delay: 0.3,
scrollTrigger: {
trigger: "#memories",
start: "top 80%"
}
});
gsap.from("#memories .memory", {
scale: 0.8,
opacity: 0,
duration: 1,
stagger: 0.2,
scrollTrigger: {
trigger: "#memories",
start: "top 80%"
}
});
// Gallery Section Animations
gsap.from("#gallery h2", {
y: 50,
opacity: 0,
duration: 1,
scrollTrigger: {
trigger: "#gallery",
start: "top 80%"
}
});
gsap.from("#gallery p", {
y: 50,
opacity: 0,
duration: 1,
delay: 0.3,
scrollTrigger: {
trigger: "#gallery",
start: "top 80%"
}
});
gsap.from("#gallery .photo", {
scale: 0.8,
opacity: 0,
duration: 1,
stagger: 0.2,
scrollTrigger: {
trigger: "#gallery",
start: "top 80%"
}
});
// Squares Section Animations
gsap.from("#squares h2", {
y: 50,
opacity: 0,
duration: 1,
scrollTrigger: {
trigger: "#squares",
start: "top 80%"
}
});
gsap.from("#squares p", {
y: 50,
opacity: 0,
duration: 1,
delay: 0.3,
scrollTrigger: {
trigger: "#squares",
start: "top 80%"
}
});
gsap.from("#squares .interaction", {
y: 50,
opacity: 0,
duration: 1,
stagger: 0.2,
scrollTrigger: {
trigger: "#squares",
start: "top 80%"
}
});
// Graffiti Section Animations
gsap.from("#graffiti h2", {
y: 50,
opacity: 0,
duration: 1,
scrollTrigger: {
trigger: "#graffiti",
start: "top 80%"
}
});
gsap.from("#graffiti p", {
y: 50,
opacity: 0,
duration: 1,
delay: 0.3,
scrollTrigger: {
trigger: "#graffiti",
start: "top 80%"
}
});
gsap.from("#graffiti .wall", {
scale: 0.8,
opacity: 0,
duration: 1,
stagger: 0.2,
scrollTrigger: {
trigger: "#graffiti",
start: "top 80%"
}
});
// Squares Interaction
const squares = document.querySelectorAll('.square');
squares.forEach(square => {
square.addEventListener('click', () => {
animateSquare(square);
});
square.addEventListener('keypress', e => {
if (e.key === 'Enter') {
animateSquare(square);
}
});
});
function animateSquare(square) {
gsap.to(square, {
scale: 1.5,
backgroundColor: "#34d399",
duration: 0.5,
yoyo: true,
repeat: 1,
ease: "power1.inOut"
});
gsap.to(square, {
rotation: 360,
duration: 1,
ease: "power2.out"
});
gsap.to(square, {
backgroundColor: "#34d399",
duration: 0.5,
onComplete: () => {
square.style.backgroundColor = "var(--primary-color)";
}
});
setTimeout(() => {
showNotification("Hey, you're very okay! You're The Squares! You're loved, and nobody is ever mad at you!");
}, 500);
}
// Graffiti Wall Lightbox
const graffitiImages = document.querySelectorAll('#graffiti .wall img');
graffitiImages.forEach(img => {
img.addEventListener('click', () => {
openLightbox(img);
});
img.addEventListener('keypress', e => {
if (e.key === 'Enter') {
openLightbox(img);
}
});
});
function openLightbox(img) {
const overlay = document.createElement('div');
overlay.classList.add('lightbox-overlay');
overlay.setAttribute('role', 'dialog');
overlay.setAttribute('aria-modal', 'true');
overlay.tabIndex = -1;
const enlargedImg = document.createElement('img');
enlargedImg.src = img.src;
enlargedImg.alt = img.alt;
enlargedImg.tabIndex = 0;
overlay.appendChild(enlargedImg);
document.body.appendChild(overlay);
gsap.to(overlay, { opacity: 1, duration: 0.5 });
const previousFocus = document.activeElement;
overlay.focus();
function closeLightbox() {
gsap.to(overlay, {
opacity: 0,
duration: 0.3,
onComplete: () => {
document.body.removeChild(overlay);
previousFocus.focus();
}
});
document.removeEventListener('keydown', escHandler);
}
overlay.addEventListener('click', closeLightbox);
enlargedImg.addEventListener('click', e => {
e.stopPropagation();
});
const escHandler = e => {
if (e.key === 'Escape') closeLightbox();
};
document.addEventListener('keydown', escHandler);
}
// Notification Function
const notification = document.getElementById('notification');
function showNotification(message) {
notification.textContent = message;
notification.classList.add('show');
setTimeout(() => {
notification.classList.remove('show');
}, 3000);
}
// Handle Window Resize
window.addEventListener('resize', () => {
renderer.setSize(window.innerWidth, window.innerHeight);
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
});
});
</script>
</body>
</html>
Key Changes and Fixes:
-
Removed integrity and crossorigin Attributes:
- These attributes can prevent scripts from loading if the integrity hash doesn't match the actual script file. By removing them, you ensure that the scripts load without these restrictions.
-
Ensured Scripts Load Correctly:
- Placed the Three.js, GSAP, and ScrollTrigger scripts before your inline script to ensure they are available when your code runs.
-
Checked for JavaScript Errors:
- Make sure to open your browser's Developer Console (usually
F12 or Ctrl+Shift+I) to check for any JavaScript errors that might still prevent the page from rendering correctly.
-
Fallback for Non-JavaScript Environments:
- Consider adding a
<noscript> tag to inform users if JavaScript is disabled, as much of your content relies on JavaScript for visibility and interactivity.
-
Improved Accessibility:
- Added
alt attributes to all images.
- Ensured interactive elements like
.square divs are keyboard accessible by adding tabindex="0" and handling keypress events.
-
Lightbox Enhancements:
- Ensured that the lightbox overlay can be closed by clicking outside the image or pressing the
Escape key.
- Managed focus to improve accessibility when the lightbox is opened and closed.
-
Responsive Design Considerations:
- Your existing media queries are preserved to ensure the site remains responsive on different screen sizes.
-
Optimized GSAP Animations:
- Ensured that all GSAP animations are properly tied to their respective scroll triggers.
Additional Recommendations:
-
Separate CSS and JavaScript Files:
- For better maintainability, consider moving your CSS into a separate
.css file and your JavaScript into a separate .js file. This approach makes the code cleaner and easier to manage as your project grows.
-
Use Modern JavaScript Practices:
- Utilize ES6+ features such as
const, let, arrow functions, and template literals for cleaner and more efficient code.
-
Optimize Image Loading:
- Use optimized images and consider implementing lazy loading for better performance.
-
Test Across Different Browsers:
- Ensure that your site works consistently across all major browsers (Chrome, Firefox, Safari, Edge).
-
Accessibility Enhancements:
- Include ARIA roles and labels where necessary to improve accessibility for users relying on assistive technologies.
-
Performance Optimization:
- Minify your CSS and JavaScript for production to reduce load times.
- Consider using a bundler like Webpack or Parcel for better asset management.
Final Thoughts
By removing the integrity and crossorigin attributes and ensuring that all scripts load correctly, your JavaScript should execute as intended, making the hidden elements visible through your GSAP animations. Always make sure to check the browser's Developer Console for any errors that might provide further clues if issues persist.
If you continue to encounter problems, feel free to share specific error messages from the console, and I can provide more targeted assistance.