From 4151b2fdec57378b1428ffa5952fd4b3f8353283 Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Wed, 26 Nov 2025 12:52:41 -0700 Subject: [PATCH] add gradient to top and bottom --- .../player/atoms/settings/TranscriptView.tsx | 51 ++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/src/components/player/atoms/settings/TranscriptView.tsx b/src/components/player/atoms/settings/TranscriptView.tsx index b9c4b689..c30ede83 100644 --- a/src/components/player/atoms/settings/TranscriptView.tsx +++ b/src/components/player/atoms/settings/TranscriptView.tsx @@ -1,5 +1,6 @@ +import classNames from "classnames"; import Fuse from "fuse.js"; -import { useEffect, useMemo, useState } from "react"; +import { useEffect, useMemo, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { Menu } from "@/components/player/internals/ContextMenu"; @@ -28,6 +29,9 @@ export function TranscriptView({ id }: { id: string }) { const { duration: timeDuration, time } = usePlayerStore((s) => s.progress); const [searchQuery, setSearchQuery] = useState(""); + const [isAtTop, setIsAtTop] = useState(true); + const [isAtBottom, setIsAtBottom] = useState(false); + const carouselRef = useRef(null); const parsedCaptions = useMemo( () => (srtData ? parseSubtitles(srtData, language) : []), @@ -121,6 +125,30 @@ export function TranscriptView({ id }: { id: string }) { return nextKey ?? activeKey; }, [filteredItems, searchQuery, time, nextKey, activeKey]); + const checkScrollPosition = () => { + const container = carouselRef.current; + if (!container) return; + + setIsAtTop(container.scrollTop <= 0); + setIsAtBottom( + Math.abs( + container.scrollHeight - container.scrollTop - container.clientHeight, + ) < 2, + ); + }; + + useEffect(() => { + const container = carouselRef.current; + if (!container) return; + + container.addEventListener("scroll", checkScrollPosition); + checkScrollPosition(); // Check initial position + + return () => { + container.removeEventListener("scroll", checkScrollPosition); + }; + }, []); + // Autoscroll with delay to prevent clashing with menu animation const [didFirstScroll, setDidFirstScroll] = useState(false); useEffect(() => { @@ -192,11 +220,20 @@ export function TranscriptView({ id }: { id: string }) { {t("player.menus.subtitles.transcriptChoice")} -
- -
- -
+ + +
+
{filteredItems.map((item) => { const html = sanitize(item.raw.replaceAll(/\r?\n/g, "
"), { ALLOWED_TAGS: ["c", "b", "i", "u", "span", "ruby", "rt", "br"], @@ -236,7 +273,7 @@ export function TranscriptView({ id }: { id: string }) { ); })}
- +
); }