mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 01:05:20 +03:00
fix: fix buggy height between image loads
This commit is contained in:
parent
6dfcc33eb8
commit
599303b35e
@ -22,6 +22,7 @@ export default function HistoryViewer({ camera }) {
|
|||||||
const [currentEvent, setCurrentEvent] = useState();
|
const [currentEvent, setCurrentEvent] = useState();
|
||||||
const [currentEventIndex, setCurrentEventIndex] = useState();
|
const [currentEventIndex, setCurrentEventIndex] = useState();
|
||||||
const [timelineOffset, setTimelineOffset] = useState(0);
|
const [timelineOffset, setTimelineOffset] = useState(0);
|
||||||
|
const [minHeight, setMinHeight] = useState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (events) {
|
if (events) {
|
||||||
@ -60,6 +61,12 @@ export default function HistoryViewer({ camera }) {
|
|||||||
setCurrentEventIndex(currentEvent.index + 1);
|
setCurrentEventIndex(currentEvent.index + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleMetadataLoad = () => {
|
||||||
|
if (videoRef.current) {
|
||||||
|
setMinHeight(videoRef.current.clientHeight);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const RenderVideo = useCallback(() => {
|
const RenderVideo = useCallback(() => {
|
||||||
return (
|
return (
|
||||||
<video
|
<video
|
||||||
@ -67,7 +74,15 @@ export default function HistoryViewer({ camera }) {
|
|||||||
onTimeUpdate={handleTimeUpdate}
|
onTimeUpdate={handleTimeUpdate}
|
||||||
onPause={handlePaused}
|
onPause={handlePaused}
|
||||||
poster={`${apiHost}/api/events/${currentEvent.id}/snapshot.jpg`}
|
poster={`${apiHost}/api/events/${currentEvent.id}/snapshot.jpg`}
|
||||||
preload='none'
|
onLoadedMetadata={handleMetadataLoad}
|
||||||
|
preload='metadata'
|
||||||
|
style={
|
||||||
|
minHeight
|
||||||
|
? {
|
||||||
|
minHeight: `${minHeight}px`,
|
||||||
|
}
|
||||||
|
: {}
|
||||||
|
}
|
||||||
playsInline
|
playsInline
|
||||||
controls
|
controls
|
||||||
>
|
>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user