Added exclusion zone
This commit is contained in:
@ -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
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user