diff --git a/src/App.css b/src/App.css index 5422ae4..5bca138 100644 --- a/src/App.css +++ b/src/App.css @@ -27,15 +27,6 @@ body { } -.main-container { - width: 100%; - height: 100%; - background-size: cover; - display: flex; - justify-content: center; - align-items: center; -} - main { height: 100%; display: flex; @@ -55,9 +46,6 @@ main { height: fit-content; } -img { - aspect-ratio: 2/3; -} #sidebar { flex-basis: calc(var(--poster-width)*2); @@ -103,6 +91,7 @@ img { height: 100%; animation: fadeImage 0.5s; animation-fill-mode: forwards; + aspect-ratio: 2/3; } } @@ -143,38 +132,19 @@ img { } } -@keyframes fadeBg { - from { - opacity: 0; - filter: blur(5rem); - } - - to { - opacity: 1; - filter: blur(0); - } -} #background { - background-color: black; + /* background-color: black; */ position: absolute; width: 100%; height: 100%; z-index: -1; - img { - width: 100%; - aspect-ratio: 16/9; - position: absolute; - } } -#current-bg { - z-index: -1; - animation: fadeBg 1s; - animation-fill-mode: forwards; -} +.CrossfadeImage { + width: 100%; + height: 100%; + -#previous-bg { - z-index: -2; } diff --git a/src/App.tsx b/src/App.tsx index 8ef3d0f..6c1e55d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,7 +6,7 @@ import React, { useState, useEffect } from 'react' import tmdb from './objects/tmdb' import { Sidebar } from './objects/sidebar' import { Movie } from './objects/movie-wall' - +import CrossfadeImage from 'react-crossfade-image' export type Config = { language: string, @@ -29,7 +29,7 @@ function App() { page: 1 }) const [movies, setMovies] = useState([new MovieClass()]) - const [backdrop, setBackdrop] = useState({ currImg: "", prevImg: "" }) + const [backdrop, setBackdrop] = useState("") const [chosenMovie, setChosenMovie] = useState(new MovieClass()) const [similarMoviesAvailable, setSimilarMoviesAvailable] = useState(true) @@ -38,45 +38,29 @@ function App() { const bgString = chosenMovie.backdrop_path ? tmdb.makeBgImgUrl(chosenMovie.backdrop_path) : tmdb.makeBgImgUrl(movies[0]?.backdrop_path ?? "") - setBackdrop(prev => { - console.log("NEW PREVIMG: " + prev.currImg) - console.log("NE CURRIMG: " + bgString) - return { - prevImg: prev.currImg, - currImg: bgString - } - }) + setBackdrop(bgString) }, [movies]) - interface BackgroundProps extends React.ComponentPropsWithRef<"div"> { - backDrop: { - currImg: string; - prevImg: string; - } - } - const Background = (props: BackgroundProps) => { - return