Skip to content

Commit 2633c97

Browse files
committed
feat: add scale event
1 parent 29b451e commit 2633c97

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mind-elixir",
3-
"version": "4.2.1",
3+
"version": "4.2.2",
44
"type": "module",
55
"description": "Mind elixir is a free open source mind map core.",
66
"keywords": [

src/interact.ts

+2
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,12 @@ export const disableEdit = function (this: MindElixirInstance) {
160160
export const scale = function (this: MindElixirInstance, scaleVal: number) {
161161
// TODO: recalculate the position of the map
162162
// plan A: use transform-origin
163+
// deprecated, center will be changed even if the scale function is doing well, which is very difficult to solve
163164
// plan B: use transform: translate
164165
// https://github.com/markmap/markmap/blob/e3071bc34da850ed7283b7d5b1a79b6c9b631a0e/packages/markmap-view/src/view.tsx#L640
165166
this.scaleVal = scaleVal
166167
this.map.style.transform = 'scale(' + scaleVal + ')'
168+
this.bus.fire('scale', scaleVal)
167169
}
168170
/**
169171
* @function

src/plugin/toolBar.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ function createToolBarRBContainer(mind: MindElixirInstance) {
3232
}
3333
zo.onclick = () => {
3434
if (mind.scaleVal < 0.6) return
35-
mind.scale((mind.scaleVal -= 0.2))
35+
mind.scale(mind.scaleVal - 0.2)
3636
}
3737
zi.onclick = () => {
3838
if (mind.scaleVal > 1.6) return
39-
mind.scale((mind.scaleVal += 0.2))
39+
mind.scale(mind.scaleVal + 0.2)
4040
}
4141
return toolBarRBContainer
4242
}

src/utils/pubsub.ts

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export type EventMap = {
8484
unselectNodes: () => void
8585
expandNode: (nodeObj: NodeObj) => void
8686
linkDiv: () => void
87+
scale: (scale: number) => void
8788
}
8889

8990
const Bus = {

0 commit comments

Comments
 (0)