Skip to content
  1. API
  2. Ogma
  3. tools

Ogma.tools.snapping

Snapping API: functions to snap nodes to guidelines while dragging them.

ogma.tools.snapping.disable()

Disables snapping mode in nodes dragging.

ogma.tools.snapping.enable([options])

Enables the snapping mode while dragging the nodes.

Arguments

  • options(optional) object
    • centerSnapDistance(optional) Number[=240] Maximum distance between 2 nodes that allowes their centers to be aligned

    • enabled(optional) Boolean[=false] Indicates whether the snapping is on when the node is being dragged

    • guidelineColor(optional) Color[='red'] Color of the axis-ligned guidelines

    • guidelineWidth(optional) Number[=1] Width of the alignment guideline

    • neighbours(optional) object Equal nodes distribution: snaps a node to the middle of the distance between two other nodes or to the same distance as two of its neighbours

      • enabled(optional) Boolean[=true] Enables the mode.
      • lineColor(optional) Color[=#00C3FF] Guideline color
      • lineWidth(optional) Number[=1] Guideline width
      • offset(optional) Number[=5] Distance between the guideline and common bounding box of aligned nodes
      • tolerance(optional) Number[=3] Snapping distance
    • preferredDistance(optional) object Options for preferred ditance snapping: pairwise snapping of the nodes based on their distance

      • enabled(optional) Boolean[=true] Enables the mode.
      • lineColor(optional) Color[=#00C3FF] Guideline color
      • lineWidth(optional) Number[=1] Guideline width
      • ratio(optional) Number[=1.13] Preferred distance ratio between nodes a and b, according to the formula d = (Ra + Rb) * ratio
      • tolerance(optional) Number[=10] Snapping distance
    • sideSnapDistanceFactor(optional) Number[=3] Maximum distance between 2 nodes that allowes their sides to be aligned. The value is the factor of dragged node diameter.

    • tolerance(optional) Number[=5] Pixel tolerance distance within which node is snapped towards the guideline