diff --git a/src/components/card/card.tsx b/src/components/card/card.tsx
index ec92105..fa672ce 100644
--- a/src/components/card/card.tsx
+++ b/src/components/card/card.tsx
@@ -54,7 +54,6 @@ const CardContent = ({
}) => {
const api = useApiInContext((s) => s.api);
const navigate = useNavigate();
- const [isHovered, setIsHovered] = useState(false);
const defaultOnClick = useCallback(() => {
if (item?.Id) {
@@ -87,18 +86,11 @@ const CardContent = ({
}
}, [item?.Id, item?.Type, navigate]);
- const handleInteractionStart = useCallback(() => setIsHovered(true), []);
- const handleInteractionEnd = useCallback(() => setIsHovered(false), []);
-
return (
>}>
@@ -168,39 +160,35 @@ const CardContent = ({
)}
{inView && !disableOverlay && (
- {isHovered && (
- <>
-
-
-
- >
- )}
+
+
+
)}
{(item.UserData?.PlaybackPositionTicks ?? -1) > 0 && (
diff --git a/src/components/carousel/carousel.scss b/src/components/carousel/carousel.scss
index 0b47e72..7d39f6f 100644
--- a/src/components/carousel/carousel.scss
+++ b/src/components/carousel/carousel.scss
@@ -11,6 +11,7 @@
&-sidebar {
overflow-y: auto;
height: 100%;
+ position: relative;
@include glass-effect($bg-color: rgba(10, 10, 14, 0.4));
border-radius: 24px;
grid-area: sidebar;
@@ -170,4 +171,8 @@
}
}
}
-}
\ No newline at end of file
+}
+.carousel-ticker-wrapper {
+scroll-margin-block: 24px;
+}
+
diff --git a/src/components/carousel/index.tsx b/src/components/carousel/index.tsx
index bd874d7..b24da91 100644
--- a/src/components/carousel/index.tsx
+++ b/src/components/carousel/index.tsx
@@ -26,18 +26,42 @@ const Carousel = ({
const [isPaused, setIsPaused] = useState(false);
const sidebarRef = React.useRef(null);
const tickerRefs = React.useRef<(HTMLDivElement | null)[]>([]);
+ const currentSlideRef = React.useRef(currentSlide);
const [setDirection] = useCarouselStore((state) => [state.setDirection]);
+ useEffect(() => {
+ currentSlideRef.current = currentSlide;
+ }, [currentSlide]);
+
useEffect(() => {
onChange(currentSlide);
// Auto-scroll sidebar to keep active item in view
- if (tickerRefs.current[currentSlide]) {
- tickerRefs.current[currentSlide]?.scrollIntoView({
- behavior: "smooth",
- block: "nearest",
- });
+ const activeTicker = tickerRefs.current[currentSlide];
+ const sidebar = sidebarRef.current;
+
+ if (activeTicker && sidebar) {
+ const sidebarTop = sidebar.scrollTop;
+ const sidebarBottom = sidebarTop + sidebar.clientHeight;
+ const activeTickerTop = activeTicker.offsetTop;
+ const activeTickerBottom =
+ activeTicker.offsetTop + activeTicker.offsetHeight;
+
+ // If element is below the visible area
+ if (activeTickerBottom > sidebarBottom) {
+ sidebar.scrollTo({
+ top: activeTickerBottom - sidebar.clientHeight + 24, // 24px padding
+ behavior: "smooth",
+ });
+ }
+ // If element is above the visible area
+ else if (activeTickerTop < sidebarTop) {
+ sidebar.scrollTo({
+ top: activeTickerTop - 24, // 24px padding
+ behavior: "smooth",
+ });
+ }
}
}, [currentSlide, content, onChange]);
@@ -57,11 +81,11 @@ const Carousel = ({
const handleTickerClick = useCallback(
(index: number) => {
- if (index === currentSlide) return;
- setDirection(index > currentSlide ? "right" : "left");
+ if (index === currentSlideRef.current) return;
+ setDirection(index > currentSlideRef.current ? "right" : "left");
setCurrentSlide(index);
},
- [currentSlide, setDirection],
+ [setDirection],
);
if (!api) return null;
@@ -85,7 +109,7 @@ const Carousel = ({
ref={(el) => {
tickerRefs.current[index] = el;
}}
- style={{ scrollMarginBlock: "24px" }}
+ className="carousel-ticker-wrapper"
>
handleTickerClick(index)}
+ onTickerClick={handleTickerClick}
+ index={index}
/>
))}
diff --git a/src/components/carousel/tickers.tsx b/src/components/carousel/tickers.tsx
index bbd828c..52d6fb8 100644
--- a/src/components/carousel/tickers.tsx
+++ b/src/components/carousel/tickers.tsx
@@ -5,37 +5,45 @@ type CarouselTickersProps = {
imageUrl?: string;
itemName: string;
itemYear: string;
- onClick: () => void;
+ onTickerClick: (index: number) => void;
+ index: number;
isActive: boolean;
};
-const CarouselTickers = ({
- imageUrl,
- itemName,
- itemYear,
- onClick,
- isActive,
-}: CarouselTickersProps) => {
- return (
-
-

-
-
- {itemName}
-
-
- {itemYear}
-
+const CarouselTickers = React.memo(
+ ({
+ imageUrl,
+ itemName,
+ itemYear,
+ onTickerClick,
+ index,
+ isActive,
+ }: CarouselTickersProps) => {
+ const handleClick = React.useCallback(() => {
+ onTickerClick(index);
+ }, [index, onTickerClick]);
+
+ return (
+
+

+
+
+ {itemName}
+
+
+ {itemYear}
+
+
-
- );
-};
+ );
+ },
+);
export default CarouselTickers;
diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts
index ada5df5..aacf35d 100644
--- a/src/routeTree.gen.ts
+++ b/src/routeTree.gen.ts
@@ -201,10 +201,10 @@ export interface FileRoutesByFullPath {
'/setup/server/add': typeof SetupServerAddRoute
'/setup/server/error': typeof SetupServerErrorRoute
'/setup/server/list': typeof SetupServerListRoute
- '/favorite': typeof ApiFavoriteIndexRoute
- '/home': typeof ApiHomeIndexRoute
- '/player': typeof ApiPlayerIndexRoute
- '/search': typeof ApiSearchIndexRoute
+ '/favorite/': typeof ApiFavoriteIndexRoute
+ '/home/': typeof ApiHomeIndexRoute
+ '/player/': typeof ApiPlayerIndexRoute
+ '/search/': typeof ApiSearchIndexRoute
'/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
}
export interface FileRoutesByTo {
@@ -292,10 +292,10 @@ export interface FileRouteTypes {
| '/setup/server/add'
| '/setup/server/error'
| '/setup/server/list'
- | '/favorite'
- | '/home'
- | '/player'
- | '/search'
+ | '/favorite/'
+ | '/home/'
+ | '/player/'
+ | '/search/'
| '/login/$userId/$userName'
fileRoutesByTo: FileRoutesByTo
to:
@@ -372,7 +372,7 @@ declare module '@tanstack/react-router' {
'/_api': {
id: '/_api'
path: ''
- fullPath: ''
+ fullPath: '/'
preLoaderRoute: typeof ApiRouteImport
parentRoute: typeof rootRouteImport
}
@@ -407,28 +407,28 @@ declare module '@tanstack/react-router' {
'/_api/search/': {
id: '/_api/search/'
path: '/search'
- fullPath: '/search'
+ fullPath: '/search/'
preLoaderRoute: typeof ApiSearchIndexRouteImport
parentRoute: typeof ApiRoute
}
'/_api/player/': {
id: '/_api/player/'
path: '/player'
- fullPath: '/player'
+ fullPath: '/player/'
preLoaderRoute: typeof ApiPlayerIndexRouteImport
parentRoute: typeof ApiRoute
}
'/_api/home/': {
id: '/_api/home/'
path: '/home'
- fullPath: '/home'
+ fullPath: '/home/'
preLoaderRoute: typeof ApiHomeIndexRouteImport
parentRoute: typeof ApiRoute
}
'/_api/favorite/': {
id: '/_api/favorite/'
path: '/favorite'
- fullPath: '/favorite'
+ fullPath: '/favorite/'
preLoaderRoute: typeof ApiFavoriteIndexRouteImport
parentRoute: typeof ApiRoute
}