Added exclusion zone

This commit is contained in:
2025-03-24 23:56:27 -06:00
parent 4300aec72d
commit c96a592849
4 changed files with 29 additions and 12 deletions

View File

@ -11,17 +11,23 @@ export const calculateZoomDelta = (
export const calculateInitialViewport = (initialZoom: number): ViewportOffset => {
// When fully zoomed out, we want to see the entire content area
// The target distribution is sized to match the viewport at minimum zoom
// So at any higher zoom level, we need to position appropriately
// Account for the UI exclusion zone at the top
const windowWidth = window.innerWidth;
const windowHeight = window.innerHeight;
// Same UI margin as in target generation
const UI_TOP_MARGIN = 100;
// Center the viewport on the target area
const areaWidth = windowWidth / CONSTANTS.ZOOM_LEVELS.min;
const areaHeight = windowHeight / CONSTANTS.ZOOM_LEVELS.min;
const areaHeight = (windowHeight - UI_TOP_MARGIN) / CONSTANTS.ZOOM_LEVELS.min;
// Account for the UI exclusion zone in Y offset
const startY = UI_TOP_MARGIN / CONSTANTS.ZOOM_LEVELS.min;
return {
x: (areaWidth - windowWidth / initialZoom) / 2,
y: (areaHeight - windowHeight / initialZoom) / 2
y: startY + (areaHeight - windowHeight / initialZoom) / 2
};
};