This commit is contained in:
Filipinos 2025-07-13 11:14:42 +02:00
parent 419bfe0ab5
commit e6106c149f
11 changed files with 75 additions and 78 deletions

View File

@ -15,7 +15,7 @@
"navHistory": { "message": "Verlauf" }, "navHistory": { "message": "Verlauf" },
"navRecommendations": { "message": "Empfehlungen" }, "navRecommendations": { "message": "Empfehlungen" },
"navMusic": { "message": "Musik" }, "navMusic": { "message": "Musik" },
"heroWelcome": { "message": "Willkommen bei CinePlex" }, "heroWelcome": { "message": "" },
"heroSubtitle": { "message": "Entdecke Tausende von Filmen und Serien." }, "heroSubtitle": { "message": "Entdecke Tausende von Filmen und Serien." },
"addStream": { "message": "Stream hinzufügen" }, "addStream": { "message": "Stream hinzufügen" },
"moreInfo": { "message": "Mehr Infos" }, "moreInfo": { "message": "Mehr Infos" },

View File

@ -15,7 +15,7 @@
"navHistory": { "message": "History" }, "navHistory": { "message": "History" },
"navRecommendations": { "message": "Recommendations" }, "navRecommendations": { "message": "Recommendations" },
"navMusic": { "message": "Music" }, "navMusic": { "message": "Music" },
"heroWelcome": { "message": "Welcome to CinePlex" }, "heroWelcome": { "message": "" },
"heroSubtitle": { "message": "Explore thousands of movies and series." }, "heroSubtitle": { "message": "Explore thousands of movies and series." },
"addStream": { "message": "Add Stream" }, "addStream": { "message": "Add Stream" },
"moreInfo": { "message": "More Info" }, "moreInfo": { "message": "More Info" },

View File

@ -15,7 +15,7 @@
"navHistory": { "message": "Historial" }, "navHistory": { "message": "Historial" },
"navRecommendations": { "message": "Recomendaciones" }, "navRecommendations": { "message": "Recomendaciones" },
"navMusic": { "message": "Música" }, "navMusic": { "message": "Música" },
"heroWelcome": { "message": "Bienvenido a CinePlex" }, "heroWelcome": { "message": "" },
"heroSubtitle": { "message": "Explora miles de películas y series." }, "heroSubtitle": { "message": "Explora miles de películas y series." },
"addStream": { "message": "Añadir Stream" }, "addStream": { "message": "Añadir Stream" },
"moreInfo": { "message": "Más información" }, "moreInfo": { "message": "Más información" },

View File

@ -15,7 +15,7 @@
"navHistory": { "message": "Historique" }, "navHistory": { "message": "Historique" },
"navRecommendations": { "message": "Recommandations" }, "navRecommendations": { "message": "Recommandations" },
"navMusic": { "message": "Musique" }, "navMusic": { "message": "Musique" },
"heroWelcome": { "message": "Bienvenue sur CinePlex" }, "heroWelcome": { "message": "" },
"heroSubtitle": { "message": "Explorez des milliers de films et de séries." }, "heroSubtitle": { "message": "Explorez des milliers de films et de séries." },
"addStream": { "message": "Ajouter le flux" }, "addStream": { "message": "Ajouter le flux" },
"moreInfo": { "message": "Plus d'infos" }, "moreInfo": { "message": "Plus d'infos" },

View File

@ -15,7 +15,7 @@
"navHistory": { "message": "Cronologia" }, "navHistory": { "message": "Cronologia" },
"navRecommendations": { "message": "Consigliati" }, "navRecommendations": { "message": "Consigliati" },
"navMusic": { "message": "Musica" }, "navMusic": { "message": "Musica" },
"heroWelcome": { "message": "Benvenuto su CinePlex" }, "heroWelcome": { "message": "" },
"heroSubtitle": { "message": "Esplora migliaia di film e serie TV." }, "heroSubtitle": { "message": "Esplora migliaia di film e serie TV." },
"addStream": { "message": "Aggiungi Stream" }, "addStream": { "message": "Aggiungi Stream" },
"moreInfo": { "message": "Più informazioni" }, "moreInfo": { "message": "Più informazioni" },

View File

@ -15,7 +15,7 @@
"navHistory": { "message": "Histórico" }, "navHistory": { "message": "Histórico" },
"navRecommendations": { "message": "Recomendações" }, "navRecommendations": { "message": "Recomendações" },
"navMusic": { "message": "Música" }, "navMusic": { "message": "Música" },
"heroWelcome": { "message": "Bem-vindo ao CinePlex" }, "heroWelcome": { "message": "" },
"heroSubtitle": { "message": "Explore milhares de filmes e séries." }, "heroSubtitle": { "message": "Explore milhares de filmes e séries." },
"addStream": { "message": "Adicionar Stream" }, "addStream": { "message": "Adicionar Stream" },
"moreInfo": { "message": "Mais Informações" }, "moreInfo": { "message": "Mais Informações" },

View File

@ -22,6 +22,10 @@
z-index: 1; z-index: 1;
} }
.hero.no-overlay::before {
display: none;
}
.hero-background-container { .hero-background-container {
position: absolute; position: absolute;
top: 0; top: 0;

View File

@ -217,6 +217,10 @@ body.light-theme .sidebar-nav {
} }
} }
body.sidebar-open .sidebar-nav {
transform: translateX(0);
}
body.sidebar-collapsed .sidebar-nav { body.sidebar-collapsed .sidebar-nav {
transform: translateX(-100%); transform: translateX(-100%);
} }

BIN
img/hero-def.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

@ -36,9 +36,12 @@ export function setupEventListeners() {
document.body.classList.remove('sidebar-collapsed'); document.body.classList.remove('sidebar-collapsed');
} }
document.getElementById('sidebar-toggle').addEventListener('click', () => { document.getElementById('sidebar-toggle').addEventListener('click', () => {
document.body.classList.toggle('sidebar-collapsed'); if (window.innerWidth < 992) {
const isCollapsed = document.body.classList.contains('sidebar-collapsed'); document.body.classList.toggle('sidebar-open');
localStorage.setItem('sidebarCollapsed', isCollapsed); } else {
document.body.classList.toggle('sidebar-collapsed');
localStorage.setItem('sidebarCollapsed', document.body.classList.contains('sidebar-collapsed'));
}
}); });
document.getElementById('nav-movies').addEventListener('click', (e) => { e.preventDefault(); switchView('movies'); }); document.getElementById('nav-movies').addEventListener('click', (e) => { e.preventDefault(); switchView('movies'); });

124
js/ui.js
View File

@ -1200,92 +1200,78 @@ export async function initializeHeroSection() {
const heroSection = document.getElementById('hero-section'); const heroSection = document.getElementById('hero-section');
if (heroSection.style.display === 'none') return; if (heroSection.style.display === 'none') return;
try { const bg1 = document.querySelector('.hero-background-1');
const type = Math.random() > 0.5 ? 'movie' : 'tv'; const bg2 = document.querySelector('.hero-background-2');
const data = await fetchTMDB(`${type}/popular?page=1`); const content = document.querySelector('.hero-content');
const popularItems = data.results.filter(i => i.backdrop_path && i.overview).slice(0, 8);
if (popularItems.length === 0) { // Set static background and show default content
heroSection.style.display = 'none'; heroSection.classList.add('no-overlay');
return; gsap.set(bg1, { backgroundImage: `url(img/hero-def.png)`, autoAlpha: 1, scale: 1 });
} gsap.set(bg2, { autoAlpha: 0 });
gsap.set(content, { autoAlpha: 1 }); // Show welcome message
heroSection.classList.remove('loading');
const bg1 = document.querySelector('.hero-background-1'); // After 5 seconds, load the dynamic content
const bg2 = document.querySelector('.hero-background-2'); setTimeout(loadTmdbHeroContent, 5000);
const content = document.querySelector('.hero-content');
let currentBg = bg1;
let nextBg = bg2;
let currentIndex = -1;
function changeHeroSlide(isFirst = false) { async function loadTmdbHeroContent() {
currentIndex = (currentIndex + 1) % popularItems.length; heroSection.classList.remove('no-overlay');
const item = popularItems[currentIndex]; try {
const nextImage = new Image(); const type = Math.random() > 0.5 ? 'movie' : 'tv';
nextImage.src = `https://image.tmdb.org/t/p/original${item.backdrop_path}`; const data = await fetchTMDB(`${type}/popular?page=1`);
const popularItems = data.results.filter(i => i.backdrop_path && i.overview).slice(0, 8);
nextImage.onload = () => { if (popularItems.length === 0) {
updateHeroContent(item); return; // Keep static image if no items
}
const heroElements = [ let currentBg = bg1;
content.querySelector('.hero-title'), let nextBg = bg2;
content.querySelector('.hero-subtitle'), let currentIndex = -1;
...content.querySelectorAll('.hero-meta-item'),
content.querySelector('.hero-buttons') function changeHeroSlide() {
]; currentIndex = (currentIndex + 1) % popularItems.length;
const item = popularItems[currentIndex];
const nextImage = new Image();
nextImage.src = `https://image.tmdb.org/t/p/original${item.backdrop_path}`;
nextImage.onload = () => {
updateHeroContent(item);
const heroElements = [
content.querySelector('.hero-title'),
content.querySelector('.hero-subtitle'),
...content.querySelectorAll('.hero-meta-item'),
content.querySelector('.hero-buttons')
];
if (isFirst) {
gsap.set(currentBg, { backgroundImage: `url(${nextImage.src})` });
gsap.to(currentBg, { autoAlpha: 1, duration: 2.5, ease: 'power2.out' });
gsap.to(content, { autoAlpha: 1, duration: 1.2, delay: 0.8, ease: 'power3.out' });
gsap.fromTo(currentBg, { scale: 1.15, transformOrigin: 'center center' }, { scale: 1, duration: 12, ease: 'none' });
heroSection.classList.remove('loading'); // Remove loading class after first slide is ready
} else {
const tl = gsap.timeline({ const tl = gsap.timeline({
onComplete: () => { onComplete: () => {
const temp = currentBg; const temp = currentBg;
currentBg = nextBg; currentBg = nextBg;
nextBg = temp; nextBg = temp;
gsap.set(nextBg, { autoAlpha: 0 }); // Reset nextBg opacity for next transition gsap.set(nextBg, { autoAlpha: 0 });
} }
}); });
tl.to(heroElements, { tl.to(heroElements, { autoAlpha: 0, y: 30, stagger: 0.08, duration: 0.6, ease: 'power3.in' }, 0);
autoAlpha: 0, gsap.set(nextBg, { backgroundImage: `url(${nextImage.src})`, autoAlpha: 0 });
y: 30, tl.to(currentBg, { autoAlpha: 0, duration: 2.5, ease: 'power2.inOut' }, 0);
stagger: 0.08, tl.to(nextBg, { autoAlpha: 1, duration: 2.5, ease: 'power2.inOut' }, 0);
duration: 0.6,
ease: 'power3.in'
}, 0); // Start content fade out at the beginning of the timeline
gsap.set(nextBg, { backgroundImage: `url(${nextImage.src})`, autoAlpha: 0 }); // Set new image and hide it
tl.to(currentBg, { autoAlpha: 0, duration: 2.5, ease: 'power2.inOut' }, 0); // Fade out current background
tl.to(nextBg, { autoAlpha: 1, duration: 2.5, ease: 'power2.inOut' }, 0); // Fade in new background simultaneously
gsap.fromTo(nextBg, { scale: 1.15, transformOrigin: 'center center' }, { scale: 1, duration: 12, ease: 'none' }); gsap.fromTo(nextBg, { scale: 1.15, transformOrigin: 'center center' }, { scale: 1, duration: 12, ease: 'none' });
tl.fromTo(heroElements, { y: -30, autoAlpha: 0 }, { y: 0, autoAlpha: 1, stagger: 0.1, duration: 1.2, ease: 'power3.out' }, '>-0.8');
};
}
tl.fromTo(heroElements, { if (state.heroIntervalId) {
y: -30, clearInterval(state.heroIntervalId);
autoAlpha: 0 }
}, { changeHeroSlide();
y: 0, state.heroIntervalId = setInterval(changeHeroSlide, 12000);
autoAlpha: 1,
stagger: 0.1, } catch (error) {
duration: 1.2, console.error("Error initializing hero section from TMDB:", error);
ease: 'power3.out'
}, '>-0.8'); // Start content fade in slightly before background transition ends
}
};
} }
gsap.set(content, { autoAlpha: 0 });
gsap.set([bg1, bg2], { autoAlpha: 0 });
changeHeroSlide(true);
state.heroIntervalId = setInterval(() => changeHeroSlide(false), 12000);
} catch (error) {
console.error("Error initializing hero section:", error);
heroSection.style.display = 'none';
} }
} }