2023-06-08 16:49:54 +08:00

1.2 KiB
Raw Blame History

KeyboardNavigation plugin

v0.2.17+

KeyboardNavigation plugin provides keyboard navigation function, that is, when you press the direction key, it will automatically find the next node and activate it.

Register

import MindMap from 'simple-mind-map'
import KeyboardNavigation from 'simple-mind-map/src/plugins/KeyboardNavigation.js'
// import KeyboardNavigation from 'simple-mind-map/src/KeyboardNavigation.js' Use this path for versions below v0.6.0

MindMap.usePlugin(KeyboardNavigation)

After registration and instantiation of MindMap, the instance can be obtained through mindMap.keyboardNavigation.

Methods

focus(dir)

dirWhich direction to find the next nodeOptional valueLeftUpRightDown

Focus on the next node

getNodeRect(node)

nodeNode

Get the location information of the node and return an object:

{
    left,
    top,
    right,
    bottom
}

getDistance(node1Rect, node2Rect)

node1Rectnode2RectThe location data of nodes can be obtained through the getNodeRect(node)

Get the distance between two nodes

getCenter(nodeRect)

nodeRectThe location data of nodes can be obtained through the getNodeRect(node)

Get the center point of the node