fix: backdrop flashing

This commit is contained in:
Prayag Prajapati committed 2024-04-27 10:25:38 +05:30
1 parent 38946a126b
commit e7af13970c
5 files changed
+584 -1989

No files matched your search

+23 -27
View File
@@ -13,56 +13,52 @@
}, },
"dependencies": { "dependencies": {
"@emotion/react": "^11.11.4", "@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0", "@emotion/styled": "^11.11.5",
"@fontsource-variable/jetbrains-mono": "^5.0.20", "@fontsource-variable/jetbrains-mono": "^5.0.21",
"@fontsource/noto-sans": "^5.0.21", "@fontsource/noto-sans": "^5.0.22",
"@jellyfin/sdk": "0.8.2", "@jellyfin/sdk": "0.8.2",
"@mui/lab": "5.0.0-alpha.169", "@mui/lab": "5.0.0-alpha.170",
"@mui/material": "^5.15.13", "@mui/material": "^5.15.15",
"@tanem/react-nprogress": "^5.0.51", "@tanem/react-nprogress": "^5.0.51",
"@tanstack/react-query": "^5.28.4", "@tanstack/react-query": "^5.32.0",
"@tanstack/react-query-devtools": "^5.28.4", "@tanstack/react-query-devtools": "^5.32.0",
"@tanstack/react-virtual": "^3.4.0", "@tanstack/react-virtual": "^3.4.0",
"@tauri-apps/api": "^1.5.3", "@tauri-apps/api": "^1.5.4",
"@types/node": "^20.11.28", "@types/node": "^20.12.7",
"@types/react": "^18.2.66", "@types/react": "^18.3.0",
"@types/react-dom": "^18.2.22", "@types/react-dom": "^18.3.0",
"axios": "^1.6.8", "axios": "^1.6.8",
"axios-tauri-api-adapter": "^0.2.1", "axios-tauri-api-adapter": "^0.2.1",
"blurhash": "^2.0.5", "blurhash": "^2.0.5",
"events": "^3.3.0", "events": "^3.3.0",
"framer-motion": "^11.0.14", "framer-motion": "^11.1.7",
"jassub": "^1.7.15", "jassub": "^1.7.15",
"material-symbols": "^0.17.0", "material-symbols": "^0.17.3",
"million": "^3.0.6", "million": "^3.0.6",
"notistack": "^3.0.1", "notistack": "^3.0.1",
"react": "^18.2.0", "react": "^18.3.1",
"react-blurhash": "^0.3.0", "react-blurhash": "^0.3.0",
"react-dom": "^18.2.0", "react-dom": "^18.3.1",
"react-error-boundary": "^4.0.13", "react-error-boundary": "^4.0.13",
"react-markdown": "^9.0.1", "react-markdown": "^9.0.1",
"react-multi-carousel": "^2.8.4", "react-multi-carousel": "^2.8.5",
"react-player": "^2.15.1", "react-player": "^2.16.0",
"react-router-dom": "^6.22.3", "react-router-dom": "^6.23.0",
"react-use-konami": "^1.1.0", "react-use-konami": "^1.1.0",
"remark-gfm": "^4.0.0", "remark-gfm": "^4.0.0",
"shaka-player": "^4.7.11",
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log#v1", "tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log#v1",
"tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store", "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store",
"typescript": "^5.4.2", "typescript": "^5.4.5",
"vite-plugin-svgr": "^4.2.0", "vite-plugin-svgr": "^4.2.0",
"wavesurfer.js": "^7.7.5", "wavesurfer.js": "^7.7.11",
"zustand": "^4.5.2" "zustand": "^4.5.2"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "^1.6.1", "@biomejs/biome": "^1.7.1",
"@tauri-apps/cli": "^1.5.11", "@tauri-apps/cli": "^1.5.12",
"@vitejs/plugin-react": "^4.2.1", "@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-refresh": "^0.4.6",
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
"sass": "^1.72.0", "sass": "^1.75.0",
"vite": "^5.1.6", "vite": "^5.1.6",
"vite-plugin-compression": "^0.5.1" "vite-plugin-compression": "^0.5.1"
}, },
+548 -1949
View File
File diff suppressed because it is too large. Load diff
+10 -11
View File
@@ -260,6 +260,12 @@ function AppReady() {
useEffect(() => window.scrollTo(0, 0), [location.key]); useEffect(() => window.scrollTo(0, 0), [location.key]);
// Reset BakcdropImageLoading for every new image
useEffect(() => {
setBackdropLoading(true);
console.debug("Image loading");
}, [backdropId]);
useLayoutEffect(() => { useLayoutEffect(() => {
async function checkForUpdates() { async function checkForUpdates() {
try { try {
@@ -407,7 +413,7 @@ function AppReady() {
<div className="app-backdrop-container"> <div className="app-backdrop-container">
<AnimatePresence> <AnimatePresence>
<motion.img <motion.img
key={`${backdropId}${backdropLoading}`} key={backdropId}
src={backdropUrl} src={backdropUrl}
alt="" alt=""
className="app-backdrop" className="app-backdrop"
@@ -421,19 +427,12 @@ function AppReady() {
opacity: 0, opacity: 0,
}} }}
transition={{ transition={{
opacity: {
duration: 1.2, duration: 1.2,
ease: "easeInOut", },
}}
onLoadCapture={() => {
setBackdropLoading(true);
}}
onLoad={() => {
setBackdropLoading(false);
}} }}
onLoad={() => setBackdropLoading(false)}
loading="lazy" loading="lazy"
style={{
transition: "opacity 1.2s",
}}
/> />
</AnimatePresence> </AnimatePresence>
</div> </div>
+2 -2
View File
@@ -360,7 +360,7 @@ const LibraryView = () => {
const scrollTrigger = useScrollTrigger({ const scrollTrigger = useScrollTrigger({
disableHysteresis: true, disableHysteresis: true,
threshold: 20, threshold: 0,
}); });
const [backdropItems, setBackdropItems] = useState([]); const [backdropItems, setBackdropItems] = useState([]);
@@ -372,7 +372,7 @@ const LibraryView = () => {
); );
setBackdropItems(backdropItemsTemp); setBackdropItems(backdropItemsTemp);
} }
}, [items.dataUpdatedAt]); }, [items.isSuccess]);
useEffect(() => { useEffect(() => {
if (backdropItems.length > 0) { if (backdropItems.length > 0) {
+1
View File
@@ -46,6 +46,7 @@ body {
} }
.app-backdrop { .app-backdrop {
transition: 1.2s;
object-fit: cover; object-fit: cover;
width: calc(100% + 160px); width: calc(100% + 160px);
height: calc(100% + 160px); height: calc(100% + 160px);