From 9fe7bdcf47aa6d04e1b10446fdf59f83a73fb0dc Mon Sep 17 00:00:00 2001 From: frost768 Date: Thu, 16 Mar 2023 21:35:22 +0300 Subject: [PATCH] change sub render positioning to absolute --- src/video/components/Caption.tsx | 1 - src/video/components/CaptionRenderer.tsx | 33 ++++++++++++++---------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/video/components/Caption.tsx b/src/video/components/Caption.tsx index 119a96a8..af3b8b80 100644 --- a/src/video/components/Caption.tsx +++ b/src/video/components/Caption.tsx @@ -17,7 +17,6 @@ export function Caption({ text }: { text?: string }) { }), }} style={{ - whiteSpace: "pre-wrap", ...captionSettings.style, }} /> diff --git a/src/video/components/CaptionRenderer.tsx b/src/video/components/CaptionRenderer.tsx index 7164232d..ed56781d 100644 --- a/src/video/components/CaptionRenderer.tsx +++ b/src/video/components/CaptionRenderer.tsx @@ -1,3 +1,4 @@ +import { Transition } from "@/components/Transition"; import { useSettings } from "@/state/settings"; import { parse, Cue } from "node-webvtt"; import { useRef } from "react"; @@ -29,7 +30,7 @@ export function CaptionRenderer({ } else { captions.current = []; } - }, [source]); + }, [source?.caption?.url]); if (!captions.current.length) return null; const isVisible = (start: number, end: number): boolean => { @@ -41,18 +42,22 @@ export function CaptionRenderer({ ); }; return ( - - {captions.current.map( - ({ identifier, end, start, text }) => - isVisible(start, end) && ( - - ) - )} - {isControlsShown ? ( -
- ) : ( -
- )} - + + + {captions.current.map( + ({ identifier, end, start, text }) => + isVisible(start, end) && ( + + ) + )} + + ); }