Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
fix for browser and vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
Enter-tainer committed Jul 29, 2023
1 parent 5109102 commit b2a95d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion addons/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script type="module" src="/src/svg.ts"></script>
</head>

<body style="padding: 0px 0px 0px 0px">
<body style="padding: 0; margin: 0;">
<div id="imageContainer"></div>
</body>
</html>
1 change: 1 addition & 0 deletions addons/frontend/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ interface Window {
handleTypstLocation(elem: Element, page: number, x: number, y: number);
typstWebsocket: WebSocket;
}
const acquireVsCodeApi: any;
10 changes: 8 additions & 2 deletions addons/frontend/src/svg-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class SvgDocument {
0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.3, 1.5, 1.7, 1.9,
2.1, 2.4, 2.7, 3, 3.3, 3.7, 4.1, 4.6, 5.1, 5.7, 6.3, 7, 7.7, 8.5, 9.4, 10,
];
this.hookedElem.addEventListener("wheel", (event) => {
const wheelEventHandler = (event: WheelEvent) => {
if (event.ctrlKey) {
event.preventDefault();

Expand Down Expand Up @@ -59,7 +59,13 @@ export class SvgDocument {
this.hookedElem.style.transformOrigin = "0 0";
this.hookedElem.style.transform = `scale(${this.currentScale})`;
}
});
};
const vscodeAPI = typeof (acquireVsCodeApi) !== "undefined";
if (vscodeAPI) {
window.addEventListener("wheel", wheelEventHandler);
} else {
document.body.addEventListener("wheel", wheelEventHandler, { passive: false });
}
}

rescale() {
Expand Down

0 comments on commit b2a95d7

Please sign in to comment.