fix: prevent slider flickering
This commit is contained in:
1 parent
183c7231a1
commit
af942149af
8 files changed
+53
-26
No files matched your search
+1
-2
@@ -3,10 +3,9 @@
|
|||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
|
|
||||||
import List from '@/components/List';
|
import List from '@/components/List';
|
||||||
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
||||||
import useUsersShows from '@/hooks/useUsersShows';
|
import useUsersShows from '@/hooks/useUsersShows';
|
||||||
|
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
list: 'favorite' | 'watchlist';
|
list: 'favorite' | 'watchlist';
|
||||||
label: string;
|
label: string;
|
||||||
@@ -2,11 +2,12 @@ import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
|||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
import { cookies } from 'next/headers';
|
import { cookies } from 'next/headers';
|
||||||
|
|
||||||
import UsersList from '@/components/UsersLists';
|
|
||||||
import usersShowsQuery from '@/data/queries/usersShows';
|
import usersShowsQuery from '@/data/queries/usersShows';
|
||||||
import { TITLE } from '@/env';
|
import { TITLE } from '@/env';
|
||||||
import getQueryClient from '@/lib/queryClient';
|
import getQueryClient from '@/lib/queryClient';
|
||||||
|
|
||||||
|
import UsersList from '../components/UsersLists';
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: `My Favorite Shows | ${TITLE}`,
|
title: `My Favorite Shows | ${TITLE}`,
|
||||||
description: `View your favorite shows on ${TITLE}. Keep track of films you’ve added and revisit your top picks anytime.`
|
description: `View your favorite shows on ${TITLE}. Keep track of films you’ve added and revisit your top picks anytime.`
|
||||||
@@ -2,11 +2,12 @@ import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
|||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
import { cookies } from 'next/headers';
|
import { cookies } from 'next/headers';
|
||||||
|
|
||||||
import UsersList from '@/components/UsersLists';
|
|
||||||
import usersShowsQuery from '@/data/queries/usersShows';
|
import usersShowsQuery from '@/data/queries/usersShows';
|
||||||
import { TITLE } from '@/env';
|
import { TITLE } from '@/env';
|
||||||
import getQueryClient from '@/lib/queryClient';
|
import getQueryClient from '@/lib/queryClient';
|
||||||
|
|
||||||
|
import UsersList from '../components/UsersLists';
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: `My watch list | ${TITLE}`,
|
title: `My watch list | ${TITLE}`,
|
||||||
description: `View your favorite shows on ${TITLE}. Keep track of films you’ve added and revisit your top picks anytime.`
|
description: `View your favorite shows on ${TITLE}. Keep track of films you’ve added and revisit your top picks anytime.`
|
||||||
+29
-4
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { ForwardedRef, forwardRef, memo, useLayoutEffect, useMemo, useRef } from 'react';
|
import { ForwardedRef, forwardRef, memo, startTransition, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { Virtuoso, VirtuosoProps } from 'react-virtuoso';
|
import { Virtuoso, VirtuosoProps } from 'react-virtuoso';
|
||||||
|
|
||||||
import Poster from '@/components/Poster';
|
import Poster from '@/components/Poster';
|
||||||
@@ -21,16 +21,34 @@ interface Props extends Context {
|
|||||||
|
|
||||||
const Carousel = memo(
|
const Carousel = memo(
|
||||||
function Carousel({ shows, gap = 8, onIndexChange, onEndReached }: Props) {
|
function Carousel({ shows, gap = 8, onIndexChange, onEndReached }: Props) {
|
||||||
|
const initialRef = useRef(true);
|
||||||
const index = useSilentIndex();
|
const index = useSilentIndex();
|
||||||
|
const [loaded, setLoaded] = useState(!index);
|
||||||
|
|
||||||
const context = useMemo(() => ({ onIndexChange, gap }), [onIndexChange, gap]);
|
const context = useMemo(
|
||||||
|
() => ({
|
||||||
|
onIndexChange,
|
||||||
|
gap
|
||||||
|
}),
|
||||||
|
[onIndexChange, gap]
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleScroll = () => {
|
||||||
|
if (loaded) return;
|
||||||
|
|
||||||
|
if (initialRef.current) return (initialRef.current = false);
|
||||||
|
|
||||||
|
startTransition(() => setLoaded(true));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='card-aspect-ratio relative mx-auto'>
|
<div className='card-aspect-ratio relative mx-auto'>
|
||||||
|
{!loaded && <Poster lazy={false} show={shows![index]} className='pointer-events-none absolute left-0 top-0' />}
|
||||||
<Virtuoso
|
<Virtuoso
|
||||||
|
onScroll={handleScroll}
|
||||||
initialItemCount={1}
|
initialItemCount={1}
|
||||||
horizontalDirection
|
horizontalDirection
|
||||||
skipAnimationFrameInResizeObserver
|
skipAnimationFrameInResizeObserver={true}
|
||||||
data={shows}
|
data={shows}
|
||||||
context={context}
|
context={context}
|
||||||
endReached={onEndReached}
|
endReached={onEndReached}
|
||||||
@@ -78,7 +96,14 @@ const components: VirtuosoProps<Show, Context>['components'] = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
List: forwardRef(function List({ context, ...props }, ref) {
|
List: forwardRef(function List({ context, ...props }, ref) {
|
||||||
return <div {...props} ref={ref} style={{ ...props.style, display: 'flex', gap: context?.gap }} />;
|
return (
|
||||||
|
<div
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
className='bg-background'
|
||||||
|
style={{ ...props.style, display: 'flex', gap: context?.gap }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
Scroller: forwardRef(function Scroller({ context, ...props }, ref) {
|
Scroller: forwardRef(function Scroller({ context, ...props }, ref) {
|
||||||
const handleRef =
|
const handleRef =
|
||||||
@@ -5,7 +5,7 @@ import { FC } from 'react';
|
|||||||
import Preview from '@/components/Preview';
|
import Preview from '@/components/Preview';
|
||||||
import Trending from '@/components/Trending';
|
import Trending from '@/components/Trending';
|
||||||
|
|
||||||
import Carousel from './(components)/Carousel';
|
import Carousel from './components/Carousel';
|
||||||
import useRandomMovie from './useRandomMovie';
|
import useRandomMovie from './useRandomMovie';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
+5
-6
@@ -1,12 +1,11 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
logging: {
|
|
||||||
fetches: {
|
|
||||||
fullUrl: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
experimental: {
|
experimental: {
|
||||||
optimizeCss: true
|
optimizeCss: true,
|
||||||
|
staleTimes: {
|
||||||
|
dynamic: 3600,
|
||||||
|
static: 3600
|
||||||
|
}
|
||||||
},
|
},
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [
|
remotePatterns: [
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
if(!self.define){let e,s={};const a=(a,c)=>(a=new URL(a+".js",c).href,s[a]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=a,e.onload=s,document.head.appendChild(e)}else e=a,importScripts(a),s()})).then((()=>{let e=s[a];if(!e)throw new Error(`Module ${a} didn’t register its module`);return e})));self.define=(c,n)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(s[i])return;let t={};const r=e=>a(e,i),o={module:{uri:i},exports:t,require:r};s[i]=Promise.all(c.map((e=>o[e]||r(e)))).then((e=>(n(...e),t)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"a3958db6876681eddff18d3d8bc16dea"},{url:"/_next/static/1bHbPMsTKkas2hcjL8h1W/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/1bHbPMsTKkas2hcjL8h1W/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/152.431d65c3703a61be.js",revision:"431d65c3703a61be"},{url:"/_next/static/chunks/159-3cd0432f95afe395.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/209-63778326bdf06d12.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/23-e0259c2123520d87.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/329-eb2b4d4edbe9c401.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/407-65a600b1664df8c5.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.48f1dfd129122432.js",revision:"48f1dfd129122432"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/620-2892144f62945cee.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/702-84b21ec277be624f.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/722-d99683acb9e8a904.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/960.03827864fd0a0451.js",revision:"03827864fd0a0451"},{url:"/_next/static/chunks/app/(site)/%5B...show%5D/page-253ab2608b9fe59a.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/(root)/page-ca0238ee859d1ddf.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/favorites/page-6217cca7628705a7.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/popular/page-8a74cbdf4bdce8ea.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/starring/page-b085eaeb88d7ff4c.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/top/page-23f6c38dac4796d1.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/(site)/watch-list/page-32589cc7a57d2425.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/_not-found/page-97bde446d7f1c840.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/app/layout-fcf4960a58d6a189.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-d1448f0cd0a3dc26.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/main-a4445f80bcd7630f.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-677ecc4b75eea214.js",revision:"1bHbPMsTKkas2hcjL8h1W"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/css/7a6e6b71a2dc9012.css",revision:"7a6e6b71a2dc9012"},{url:"/_next/static/media/a9b1453781eac9e6-s.p.woff2",revision:"c754cf60aba699077f00948285Line truncated
|
if(!self.define){let e,s={};const c=(c,n)=>(c=new URL(c+".js",n).href,s[c]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=c,e.onload=s,document.head.appendChild(e)}else e=c,importScripts(c),s()})).then((()=>{let e=s[c];if(!e)throw new Error(`Module ${c} didn’t register its module`);return e})));self.define=(n,a)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(s[i])return;let t={};const r=e=>c(e,i),o={module:{uri:i},exports:t,require:r};s[i]=Promise.all(n.map((e=>o[e]||r(e)))).then((e=>(a(...e),t)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"ca4faa54df5481a7fc46ba9f04a6664e"},{url:"/_next/static/chunks/152.431d65c3703a61be.js",revision:"431d65c3703a61be"},{url:"/_next/static/chunks/159-3cd0432f95afe395.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/209-63778326bdf06d12.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/23-e0259c2123520d87.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/329-eb2b4d4edbe9c401.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/407-41a51daa5acff848.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.48f1dfd129122432.js",revision:"48f1dfd129122432"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/620-2892144f62945cee.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/702-84b21ec277be624f.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/722-d99683acb9e8a904.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/960.03827864fd0a0451.js",revision:"03827864fd0a0451"},{url:"/_next/static/chunks/app/(site)/%5B...show%5D/page-253ab2608b9fe59a.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/app/(site)/(root)/page-ca0238ee859d1ddf.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/app/(site)/favorites/page-6217cca7628705a7.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/app/(site)/popular/page-8a74cbdf4bdce8ea.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/app/(site)/starring/page-b085eaeb88d7ff4c.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/app/(site)/top/page-23f6c38dac4796d1.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/app/(site)/watch-list/page-32589cc7a57d2425.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/app/_not-found/page-97bde446d7f1c840.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/app/layout-fcf4960a58d6a189.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-d1448f0cd0a3dc26.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/main-a4445f80bcd7630f.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-677ecc4b75eea214.js",revision:"d6ny2CcoRaswIxkcTM_r5"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/css/f64b657144546124.css",revision:"f64b657144546124"},{url:"/_next/static/d6ny2CcoRaswIxkcTM_r5/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/d6ny2CcoRaswIxkcTM_r5/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/media/a9b1453781eac9e6-s.p.woff2",revision:"c754cf60aba699077f00948285Line truncated
|
||||||
+12
-10
@@ -87,18 +87,20 @@
|
|||||||
background: hsl(var(--secondary-foreground));
|
background: hsl(var(--secondary-foreground));
|
||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar {
|
@media not all and (hover: none) {
|
||||||
width: 6px;
|
::-webkit-scrollbar {
|
||||||
background-color: transparent;
|
width: 6px;
|
||||||
}
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb {
|
::-webkit-scrollbar-thumb {
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background-color: hsl(var(--foreground));
|
background-color: hsl(var(--foreground));
|
||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb:hover {
|
::-webkit-scrollbar-thumb:hover {
|
||||||
background-color: hsl(var(--muted-foreground));
|
background-color: hsl(var(--muted-foreground));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|||||||
Reference in new issue
Block a user