Skip to content

Commit

Permalink
Fix: zoom and pan control responsiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Mar 9, 2024
1 parent 3ca4cff commit 67f7751
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/workspace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export const Workspace: React.FC<ISTKProps> = (props) => {
[selectedElementIds]
);

const showZoomControls = props.options?.showZoomControls ?? true;

return (
<div
id={ids.workspaceContainer}
Expand Down Expand Up @@ -119,7 +121,7 @@ export const Workspace: React.FC<ISTKProps> = (props) => {
<Grid />
</>
)}
<Zoom {...props} />
{showZoomControls && <Zoom {...props} />}
</div>
);
};
Expand Down
6 changes: 5 additions & 1 deletion src/components/workspace/zoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ const Zoom = (props: ISTKProps) => {
return (
<div
id={ids.zoomControls}
className={twMerge("fixed bottom-14 left-20 flex flex-col items-center gap-4", zoomStyles?.root?.className)}
className={twMerge(
"fixed bottom-14 left-20 flex flex-col items-center gap-4",
props.mode === "user" && "bottom-5 left-6 sm:bottom-6 sm:left-8 md:bottom-8 md:left-10",
zoomStyles?.root?.className
)}
style={zoomStyles?.root?.properties}
>
<div
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/events/workspace-load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const useWorkspaceLoad = (props: ISTKProps) => {
const scaleFactor = 1.05;
panAndZoom({
k: scaleFactor,
y: (workspaceheight - (wgOffsetTop * scaleFactor * 2 + workspaceGroupHeight * scaleFactor)) / 2 - 5,
y: (workspaceheight - (wgOffsetTop * scaleFactor * 2 + workspaceGroupHeight * scaleFactor)) / 2 - 7,
x: (workspaceWidth - (wgOffsetLeft * scaleFactor * 2 + workspaceGroupWidth * scaleFactor)) / 2
});
}, 0);
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface ISTKProps {
showGridSwitch?: boolean;
showSeatLabels?: boolean;
showFooter?: boolean;
showZoomControls?: boolean;
exportButtonText?: string;
operationTriggerIcon?: React.FC;
};
Expand Down

0 comments on commit 67f7751

Please sign in to comment.