Skip to content

Commit

Permalink
subtract scrollBarWidth from scaledWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernt Christian Egeland authored and NickM-27 committed Feb 4, 2023
1 parent 6c10e3d commit 6583244
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions web/src/components/CameraImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function CameraImage({ camera, onload, searchParams = '', stretch

// Add scrollbar width (when visible) to the available observer width to eliminate screen juddering.
// https://github.com/blakeblackshear/frigate/issues/1657
let scrollBarWidth;
let scrollBarWidth = 0;
if (window.innerWidth && document.body.offsetWidth) {
scrollBarWidth = window.innerWidth - document.body.offsetWidth;
}
Expand All @@ -30,7 +30,10 @@ export default function CameraImage({ camera, onload, searchParams = '', stretch
const scaledHeight = Math.floor(availableWidth / aspectRatio);
return stretch ? scaledHeight : Math.min(scaledHeight, height);
}, [availableWidth, aspectRatio, height, stretch]);
const scaledWidth = useMemo(() => Math.ceil(scaledHeight * aspectRatio), [scaledHeight, aspectRatio]);
const scaledWidth = useMemo(() => Math.ceil(scaledHeight * aspectRatio - scrollBarWidth), [
scaledHeight,
aspectRatio,
]);

const img = useMemo(() => new Image(), []);
img.onload = useCallback(
Expand Down

0 comments on commit 6583244

Please sign in to comment.