|
|
@ -4,7 +4,7 @@ import { EpisodeSelectionPopout } from "@/video/components/popouts/EpisodeSelect |
|
|
|
import { useVideoPlayerDescriptor } from "@/video/state/hooks"; |
|
|
|
import { useVideoPlayerDescriptor } from "@/video/state/hooks"; |
|
|
|
import { useControls } from "@/video/state/logic/controls"; |
|
|
|
import { useControls } from "@/video/state/logic/controls"; |
|
|
|
import { useInterface } from "@/video/state/logic/interface"; |
|
|
|
import { useInterface } from "@/video/state/logic/interface"; |
|
|
|
import { useCallback, useEffect, useMemo, useState } from "react"; |
|
|
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react"; |
|
|
|
|
|
|
|
|
|
|
|
import "./Popouts.css"; |
|
|
|
import "./Popouts.css"; |
|
|
|
|
|
|
|
|
|
|
@ -20,8 +20,9 @@ function ShowPopout(props: { popoutId: string | null }) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO improve anti offscreen math
|
|
|
|
// TODO bug: first load ref is null
|
|
|
|
export function PopoutProviderAction() { |
|
|
|
export function PopoutProviderAction() { |
|
|
|
|
|
|
|
const ref = useRef<HTMLDivElement>(null); |
|
|
|
const descriptor = useVideoPlayerDescriptor(); |
|
|
|
const descriptor = useVideoPlayerDescriptor(); |
|
|
|
const videoInterface = useInterface(descriptor); |
|
|
|
const videoInterface = useInterface(descriptor); |
|
|
|
const controls = useControls(descriptor); |
|
|
|
const controls = useControls(descriptor); |
|
|
@ -32,19 +33,23 @@ export function PopoutProviderAction() { |
|
|
|
}, [controls]); |
|
|
|
}, [controls]); |
|
|
|
|
|
|
|
|
|
|
|
const distanceFromRight = useMemo(() => { |
|
|
|
const distanceFromRight = useMemo(() => { |
|
|
|
return videoInterface.popoutBounds |
|
|
|
if (!videoInterface.popoutBounds) return 30; |
|
|
|
? `${Math.max( |
|
|
|
|
|
|
|
window.innerWidth - |
|
|
|
const buttonCenter = |
|
|
|
videoInterface.popoutBounds.right - |
|
|
|
videoInterface.popoutBounds.left + videoInterface.popoutBounds.width / 2; |
|
|
|
videoInterface.popoutBounds.width / 2, |
|
|
|
|
|
|
|
30 |
|
|
|
return Math.max( |
|
|
|
)}px` |
|
|
|
window.innerWidth - |
|
|
|
: "30px"; |
|
|
|
buttonCenter - |
|
|
|
|
|
|
|
(ref.current?.getBoundingClientRect().width ?? 0) / 2, |
|
|
|
|
|
|
|
30 |
|
|
|
|
|
|
|
); |
|
|
|
}, [videoInterface.popoutBounds]); |
|
|
|
}, [videoInterface.popoutBounds]); |
|
|
|
|
|
|
|
|
|
|
|
const distanceFromBottom = useMemo(() => { |
|
|
|
const distanceFromBottom = useMemo(() => { |
|
|
|
return videoInterface.popoutBounds |
|
|
|
return videoInterface.popoutBounds |
|
|
|
? `${videoInterface.popoutBounds.height + 30}px` |
|
|
|
? videoInterface.popoutBounds.height + 30 |
|
|
|
: "30px"; |
|
|
|
: 30; |
|
|
|
}, [videoInterface.popoutBounds]); |
|
|
|
}, [videoInterface.popoutBounds]); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
@ -56,10 +61,11 @@ export function PopoutProviderAction() { |
|
|
|
<div className="popout-wrapper pointer-events-auto absolute inset-0"> |
|
|
|
<div className="popout-wrapper pointer-events-auto absolute inset-0"> |
|
|
|
<div onClick={handleClick} className="absolute inset-0" /> |
|
|
|
<div onClick={handleClick} className="absolute inset-0" /> |
|
|
|
<div |
|
|
|
<div |
|
|
|
|
|
|
|
ref={ref} |
|
|
|
className="absolute z-10 grid h-[500px] w-80 grid-rows-[auto,minmax(0,1fr)] overflow-hidden rounded-lg bg-ash-200" |
|
|
|
className="absolute z-10 grid h-[500px] w-80 grid-rows-[auto,minmax(0,1fr)] overflow-hidden rounded-lg bg-ash-200" |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
right: distanceFromRight, |
|
|
|
right: `${distanceFromRight}px`, |
|
|
|
bottom: distanceFromBottom, |
|
|
|
bottom: `${distanceFromBottom}px`, |
|
|
|
}} |
|
|
|
}} |
|
|
|
> |
|
|
|
> |
|
|
|
<ShowPopout popoutId={videoInterface.popout} /> |
|
|
|
<ShowPopout popoutId={videoInterface.popout} /> |
|
|
|