mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-23 16:48:23 +03:00
refactor(web): trim live zoom module to shared primitives only
This commit is contained in:
parent
2d9508bbd8
commit
36e9c63e91
61
web/src/views/live/liveZoom.ts
Normal file
61
web/src/views/live/liveZoom.ts
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import { type CSSProperties } from "react";
|
||||||
|
import { ReactZoomPanPinchProps } from "react-zoom-pan-pinch";
|
||||||
|
|
||||||
|
export type LiveZoomMode = "player" | "debug";
|
||||||
|
|
||||||
|
export type LiveZoomWrapperProps = Pick<
|
||||||
|
ReactZoomPanPinchProps,
|
||||||
|
"minScale" | "wheel" | "disabled"
|
||||||
|
>;
|
||||||
|
|
||||||
|
export type LiveZoomTransformStyles = {
|
||||||
|
wrapperStyle: CSSProperties;
|
||||||
|
contentStyle: CSSProperties;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const LIVE_ZOOM_WHEEL_CONFIG: NonNullable<
|
||||||
|
ReactZoomPanPinchProps["wheel"]
|
||||||
|
> = {
|
||||||
|
smoothStep: 0.005,
|
||||||
|
};
|
||||||
|
|
||||||
|
const LIVE_ZOOM_TRANSFORM_STYLES: Record<LiveZoomMode, LiveZoomTransformStyles> =
|
||||||
|
{
|
||||||
|
player: {
|
||||||
|
wrapperStyle: {
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
},
|
||||||
|
contentStyle: {
|
||||||
|
position: "relative",
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
padding: "8px",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
debug: {
|
||||||
|
wrapperStyle: {
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
},
|
||||||
|
contentStyle: {
|
||||||
|
position: "relative",
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export function createLiveZoomWrapperProps(disabled: boolean): LiveZoomWrapperProps {
|
||||||
|
return {
|
||||||
|
minScale: 1,
|
||||||
|
wheel: LIVE_ZOOM_WHEEL_CONFIG,
|
||||||
|
disabled,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLiveZoomTransformStyles(
|
||||||
|
mode: LiveZoomMode,
|
||||||
|
): LiveZoomTransformStyles {
|
||||||
|
return LIVE_ZOOM_TRANSFORM_STYLES[mode];
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user