hero fix
This commit is contained in:
parent
419bfe0ab5
commit
e6106c149f
@ -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" },
|
||||||
|
@ -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" },
|
||||||
|
@ -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" },
|
||||||
|
@ -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" },
|
||||||
|
@ -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" },
|
||||||
|
@ -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" },
|
||||||
|
@ -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;
|
||||||
|
@ -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
BIN
img/hero-def.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 MiB |
@ -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', () => {
|
||||||
|
if (window.innerWidth < 992) {
|
||||||
|
document.body.classList.toggle('sidebar-open');
|
||||||
|
} else {
|
||||||
document.body.classList.toggle('sidebar-collapsed');
|
document.body.classList.toggle('sidebar-collapsed');
|
||||||
const isCollapsed = document.body.classList.contains('sidebar-collapsed');
|
localStorage.setItem('sidebarCollapsed', document.body.classList.contains('sidebar-collapsed'));
|
||||||
localStorage.setItem('sidebarCollapsed', isCollapsed);
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('nav-movies').addEventListener('click', (e) => { e.preventDefault(); switchView('movies'); });
|
document.getElementById('nav-movies').addEventListener('click', (e) => { e.preventDefault(); switchView('movies'); });
|
||||||
|
76
js/ui.js
76
js/ui.js
@ -1200,24 +1200,36 @@ 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;
|
||||||
|
|
||||||
|
const bg1 = document.querySelector('.hero-background-1');
|
||||||
|
const bg2 = document.querySelector('.hero-background-2');
|
||||||
|
const content = document.querySelector('.hero-content');
|
||||||
|
|
||||||
|
// Set static background and show default content
|
||||||
|
heroSection.classList.add('no-overlay');
|
||||||
|
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');
|
||||||
|
|
||||||
|
// After 5 seconds, load the dynamic content
|
||||||
|
setTimeout(loadTmdbHeroContent, 5000);
|
||||||
|
|
||||||
|
async function loadTmdbHeroContent() {
|
||||||
|
heroSection.classList.remove('no-overlay');
|
||||||
try {
|
try {
|
||||||
const type = Math.random() > 0.5 ? 'movie' : 'tv';
|
const type = Math.random() > 0.5 ? 'movie' : 'tv';
|
||||||
const data = await fetchTMDB(`${type}/popular?page=1`);
|
const data = await fetchTMDB(`${type}/popular?page=1`);
|
||||||
const popularItems = data.results.filter(i => i.backdrop_path && i.overview).slice(0, 8);
|
const popularItems = data.results.filter(i => i.backdrop_path && i.overview).slice(0, 8);
|
||||||
|
|
||||||
if (popularItems.length === 0) {
|
if (popularItems.length === 0) {
|
||||||
heroSection.style.display = 'none';
|
return; // Keep static image if no items
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bg1 = document.querySelector('.hero-background-1');
|
|
||||||
const bg2 = document.querySelector('.hero-background-2');
|
|
||||||
const content = document.querySelector('.hero-content');
|
|
||||||
let currentBg = bg1;
|
let currentBg = bg1;
|
||||||
let nextBg = bg2;
|
let nextBg = bg2;
|
||||||
let currentIndex = -1;
|
let currentIndex = -1;
|
||||||
|
|
||||||
function changeHeroSlide(isFirst = false) {
|
function changeHeroSlide() {
|
||||||
currentIndex = (currentIndex + 1) % popularItems.length;
|
currentIndex = (currentIndex + 1) % popularItems.length;
|
||||||
const item = popularItems[currentIndex];
|
const item = popularItems[currentIndex];
|
||||||
const nextImage = new Image();
|
const nextImage = new Image();
|
||||||
@ -1233,59 +1245,33 @@ export async function initializeHeroSection() {
|
|||||||
content.querySelector('.hero-buttons')
|
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, {
|
|
||||||
y: -30,
|
|
||||||
autoAlpha: 0
|
|
||||||
}, {
|
|
||||||
y: 0,
|
|
||||||
autoAlpha: 1,
|
|
||||||
stagger: 0.1,
|
|
||||||
duration: 1.2,
|
|
||||||
ease: 'power3.out'
|
|
||||||
}, '>-0.8'); // Start content fade in slightly before background transition ends
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
gsap.set(content, { autoAlpha: 0 });
|
if (state.heroIntervalId) {
|
||||||
gsap.set([bg1, bg2], { autoAlpha: 0 });
|
clearInterval(state.heroIntervalId);
|
||||||
|
}
|
||||||
changeHeroSlide(true);
|
changeHeroSlide();
|
||||||
state.heroIntervalId = setInterval(() => changeHeroSlide(false), 12000);
|
state.heroIntervalId = setInterval(changeHeroSlide, 12000);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error initializing hero section:", error);
|
console.error("Error initializing hero section from TMDB:", error);
|
||||||
heroSection.style.display = 'none';
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user