Panning, modeChange Event, minor changes (#939)

* mode event, panning cursor

* Panning shortcuts(space,wheel), undo shortcut

* Undo/redo shortcuts, svgcanvas changes added to the main file

* minor refactoring
This commit is contained in:
olekhshch
2023-12-28 11:20:26 +01:00
committed by GitHub
parent d502525cc0
commit 19403a2755
7 changed files with 156 additions and 62 deletions

View File

@@ -308,6 +308,9 @@ class SvgCanvas {
this.contentW = this.getResolution().w
this.contentH = this.getResolution().h
this.clear()
// creates custom modeEvent for editor
this.modeChangeEvent()
} // End constructor
getSvgOption () {
@@ -827,6 +830,11 @@ class SvgCanvas {
? this.curText
: this.curShape
this.currentMode = name
// fires modeChange event for the editor
if (this.modeEvent) {
document.dispatchEvent(this.modeEvent)
}
}
/**
@@ -1328,6 +1336,14 @@ class SvgCanvas {
this.decode64 = decode64
this.mergeDeep = mergeDeep
}
/**
* Creates modeChange event, adds it as an svgCanvas property
* **/
modeChangeEvent () {
const modeEvent = new CustomEvent('modeChange', { detail: { getMode: () => this.getMode() } })
this.modeEvent = modeEvent
}
} // End class
// attach utilities function to the class that are used by SvgEdit so