diff --git a/src/components/itemBackdrop/index.tsx b/src/components/itemBackdrop/index.tsx index 5e8b3c8..6c4619c 100644 --- a/src/components/itemBackdrop/index.tsx +++ b/src/components/itemBackdrop/index.tsx @@ -1,4 +1,5 @@ import { + AnimatePresence, type HTMLMotionProps, motion, useScroll, @@ -17,6 +18,15 @@ interface ItemBackdropProps { motionProps?: HTMLMotionProps<"img">; } +const MotionImg = motion.img; + +const animationProps = { + initial: { opacity: 0 }, + animate: { opacity: 1 }, + exit: { opacity: 0 }, + transition: { duration: 0.5 }, +}; + /** * ItemBackdrop delays applying motion-driven parallax until after mount * to avoid hydration timing errors ("Target ref is defined but not hydrated"). @@ -24,7 +34,7 @@ interface ItemBackdropProps { * attached, it renders a static img to prevent motion from touching an * unhydrated DOM node. */ -function ItemBackdropContent({ +const ItemBackdropContent = React.memo(function ItemBackdropContent({ targetRef, src, alt, @@ -47,19 +57,18 @@ function ItemBackdropContent({ }); const y = useTransform(scrollYProgress, [0, 1], [-distance, distance]); return ( - { - e.currentTarget.style.opacity = "1"; onLoad?.(e); }} style={{ y }} {...motionProps} /> ); -} +}); export function ItemBackdrop({ targetRef, @@ -90,6 +99,14 @@ export function ItemBackdrop({ return () => cancelAnimationFrame(raf); }, [targetRef, ready]); + const finalMotionProps = React.useMemo( + () => ({ + ...animationProps, + ...motionProps, + }), + [motionProps], + ); + if (!ready) { return ( {alt} + + + ); } diff --git a/src/components/itemHeader/index.tsx b/src/components/itemHeader/index.tsx index 6d74eb1..5e217c7 100644 --- a/src/components/itemHeader/index.tsx +++ b/src/components/itemHeader/index.tsx @@ -35,6 +35,7 @@ interface ItemHeaderProps { mediaQualityInfo?: MediaQualityInfo; scrollTargetRef?: RefObject; children?: ReactNode; + backdropSrc?: string | null; } const ItemHeader = ({ @@ -43,6 +44,7 @@ const ItemHeader = ({ mediaQualityInfo, scrollTargetRef, children, + backdropSrc, }: ItemHeaderProps) => { const isEpisode = item.Type === "Episode"; const backdropTag = @@ -61,7 +63,7 @@ const ItemHeader = ({ const logoId = isEpisode && parentLogoImageTag ? (item.SeriesId ?? item.Id) : item.Id; - const LogoOrTitle = () => + const logo = logoTag ? ( {item.Name @@ -156,10 +159,10 @@ const ItemHeader = ({ width: "fit-content", }} > - + {logo} ) : ( - + logo )} {isEpisode && ( diff --git a/src/components/itemHeader/itemHeader.scss b/src/components/itemHeader/itemHeader.scss index 308adca..ccaa3de 100644 --- a/src/components/itemHeader/itemHeader.scss +++ b/src/components/itemHeader/itemHeader.scss @@ -75,6 +75,9 @@ $cardWidth: 18%; object-fit: cover; object-position: top; opacity: 0; + position: absolute; + top: 0; + left: 0; transition: opacity $transition-time-default; &-container { filter: brightness(0.8); diff --git a/src/routes/_api/series/$id.tsx b/src/routes/_api/series/$id.tsx index 49c4486..bf53061 100644 --- a/src/routes/_api/series/$id.tsx +++ b/src/routes/_api/series/$id.tsx @@ -303,7 +303,12 @@ function SeriesTitlePage() { className="scrollY padded-top flex flex-column item item-series" ref={containerRef} > - +