Skip to content

Commit af981c2

Browse files
committed
feat(event): add changeDirection event for mind map direction changes
1 parent 6814ba8 commit af981c2

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/dev.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ mind.bus.addListener('selectNodes', nodes => {
167167
mind.bus.addListener('unselectNodes', nodes => {
168168
console.log('unselectNodes', nodes)
169169
})
170-
mind.bus.addListener('expandNode', node => {
171-
console.log('expandNode: ', node)
170+
mind.bus.addListener('changeDirection', direction => {
171+
console.log('changeDirection: ', direction)
172172
})
173173

174174
const dl2 = async () => {

src/interact.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ export const initLeft = function (this: MindElixirInstance) {
271271
this.direction = 0
272272
this.refresh()
273273
this.toCenter()
274+
this.bus.fire('changeDirection', this.direction)
274275
}
275276
/**
276277
* @function
@@ -283,6 +284,7 @@ export const initRight = function (this: MindElixirInstance) {
283284
this.direction = 1
284285
this.refresh()
285286
this.toCenter()
287+
this.bus.fire('changeDirection', this.direction)
286288
}
287289
/**
288290
* @function
@@ -295,6 +297,7 @@ export const initSide = function (this: MindElixirInstance) {
295297
this.direction = 2
296298
this.refresh()
297299
this.toCenter()
300+
this.bus.fire('changeDirection', this.direction)
298301
}
299302

300303
/**

src/utils/pubsub.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export type EventMap = {
7575
selectNodes: (nodeObj: NodeObj[]) => void
7676
unselectNodes: (nodeObj: NodeObj[]) => void
7777
expandNode: (nodeObj: NodeObj) => void
78+
changeDirection: (direction: number) => void
7879
linkDiv: () => void
7980
scale: (scale: number) => void
8081
move: (data: { dx: number; dy: number }) => void

0 commit comments

Comments
 (0)