From 774885e9cdacfe1e6e50487afb1edff3e94958a8 Mon Sep 17 00:00:00 2001 From: zombozo12 Date: Sat, 23 Mar 2024 00:06:59 +0700 Subject: [PATCH 1/2] added panzoom --- package.json | 3 ++- src/processor.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 53e2c00..0a83b70 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ }, "dependencies": { "child_process": "^1.0.2", - "lodash.debounce": "^4.0.8" + "lodash.debounce": "^4.0.8", + "panzoom": "^9.4.3" } } diff --git a/src/processor.ts b/src/processor.ts index c691bfc..e295b52 100644 --- a/src/processor.ts +++ b/src/processor.ts @@ -3,9 +3,13 @@ import { exec, execSync } from "child_process"; import { delimiter } from "path"; import debounce from "lodash.debounce"; import os from "os"; +import panzoom from 'panzoom'; import D2Plugin from "./main"; +const MIN_ZOOM = 0.1; +const MAX_ZOOM = 15; + export class D2Processor { plugin: D2Plugin; debouncedMap: Map< @@ -118,6 +122,13 @@ export class D2Processor { this.formatLinks(svgEl); containerEl.innerHTML = this.sanitizeSVGIDs(svgEl, ctx.docId); + panzoom(containerEl, { + maxZoom: MAX_ZOOM, + minZoom: MIN_ZOOM, + beforeWheel: (e) => { + return !e.ctrlKey; + }, + }) } export = async ( From f75d8eeed1c09f406a448211396e1226b12fbd19 Mon Sep 17 00:00:00 2001 From: zombozo12 Date: Mon, 25 Mar 2024 15:28:25 +0700 Subject: [PATCH 2/2] fix ci --- src/processor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/processor.ts b/src/processor.ts index e295b52..c202632 100644 --- a/src/processor.ts +++ b/src/processor.ts @@ -3,7 +3,7 @@ import { exec, execSync } from "child_process"; import { delimiter } from "path"; import debounce from "lodash.debounce"; import os from "os"; -import panzoom from 'panzoom'; +import panzoom from "panzoom"; import D2Plugin from "./main"; @@ -128,7 +128,7 @@ export class D2Processor { beforeWheel: (e) => { return !e.ctrlKey; }, - }) + }); } export = async (