Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GuidedDraggingTool Extension

This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. Extensions can be found in the GoJS kit under the extensions (for loading via script tags),extensionsTS (UMD modules), or extensionsJSM (ES6 modules) folders. See the Extensions intro page for more information.

Hierarchy

The GuidedDraggingTool class makes guidelines visible as the parts are dragged around a diagram when the selected part is nearly aligned with another part.

If you want to experiment with this extension, try the Guided Dragging sample.

Index

Inherited Members

Constructors

  • Constructs a GuidedDraggingTool and sets up the temporary guideline parts.

    Returns GuidedDraggingTool

Properties

  • Gets or sets the color of center guidelines.

    The default value is "gray".

  • Gets or sets the margin of error for which guidelines show up.

    The default value is 6. Guidelines will show up when the aligned nodes are ± 6px away from perfect alignment.

  • Gets or sets the strokeWidth of the guidelines.

    The default value is 1.

  • Gets or sets the color of horizontal guidelines.

    The default value is "gray".

  • Gets or sets whether the guidelines are enabled or disables.

    The default value is true.

  • Gets or sets whether snapping to guidelines is enabled.

    The default value is true.

  • Gets or sets the distance around the selected part to search for aligned parts.

    The default value is 1000. Set this to Infinity if you want to search the entire diagram no matter how far away.

  • Gets or sets the color of vertical guidelines.

    The default value is "gray".

Properties

Methods

  • clearGuidelines(): void
  • Removes all of the guidelines from the grid.

    Returns void

  • doDeactivate(): void
  • Calls the base method and removes the guidelines from the graph.

    Returns void

  • Shows vertical and horizontal guidelines for the dragged part.

    Parameters

    Returns void

  • On a mouse-up, snaps the selected part to the nearest guideline. If not snapping, the part remains at its position.

    Parameters

    Returns void

  • invalidateLinks(node: Part): void
  • When nodes are shifted due to being guided upon a drop, make sure all connected link routes are invalidated, since the node is likely to have moved a different amount than all its connected links in the regular operation of the DraggingTool.

    Parameters

    Returns void

  • isGuiding(part: Part, guidedpart: Part): boolean
  • This predicate decides whether or not the given Part should guide the dragged part.

    Parameters

    • part: Part

      a stationary Part to which the dragged part might be aligned

    • guidedpart: Part

      the Part being dragged

    Returns boolean

  • showHorizontalMatches(part: Part, guideline: boolean, snap: boolean): void
  • This finds parts that are aligned near the selected part along horizontal lines. It compares the selected part to all parts within a rectangle approximately twice the searchDistance wide. The guidelines appear when a part is aligned within a margin-of-error equal to guidelineSnapDistance.

    Parameters

    • part: Part
    • guideline: boolean

      if true, show guideline

    • snap: boolean

      if true, snap the part to where the guideline would be

    Returns void

  • showVerticalMatches(part: Part, guideline: boolean, snap: boolean): void
  • This finds parts that are aligned near the selected part along vertical lines. It compares the selected part to all parts within a rectangle approximately twice the searchDistance tall. The guidelines appear when a part is aligned within a margin-of-error equal to guidelineSnapDistance.

    Parameters

    • part: Part
    • guideline: boolean

      if true, show guideline

    • snap: boolean

      if true, don't show guidelines but just snap the part to where the guideline would be

    Returns void