Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom canvas #85

Merged
merged 10 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Reformatted demo website to horizontal layout.
- Added more documentation for the `--output` flag.
- Added zoom functionality to output canvas.

### 🔧 Internal changes

Expand Down
3 changes: 2 additions & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"memory-viz": "*",
"react": "^18.3.1",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.12"
"react-error-boundary": "^4.0.12",
"react-zoom-pan-pinch": "^3.6.1"
}
}
29 changes: 22 additions & 7 deletions demo/src/SvgDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useRef, useEffect } from "react";
import mem from "memory-viz";
import { Paper } from "@mui/material";
import { configDataPropTypes } from "./MemoryModelsUserInput";
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";

type SvgDisplayPropTypes = {
jsonResult: object | null;
Expand Down Expand Up @@ -33,16 +34,30 @@ export default function SvgDisplay(props: SvgDisplayPropTypes) {
<Paper
sx={{
height: 500,
overflow: "auto",
overflow: "hidden",
display: "flex",
justifyContent: "center",
alignItems: "center",
}}
variant="outlined"
>
<canvas
data-testid="memory-models-canvas"
ref={canvasRef}
width={canvasWidth}
height={canvasHeight}
/>
<TransformWrapper
minScale={0.2}
wheel={{ step: 0.2, smoothStep: 0.01 }}
>
<TransformComponent>
<canvas
style={{
height: "100%",
width: "100%",
}}
data-testid="memory-models-canvas"
ref={canvasRef}
width={canvasWidth}
height={canvasHeight}
/>
</TransformComponent>
</TransformWrapper>
</Paper>
);
}
Expand Down
17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading