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` or `extensionsTS` folders. See the Extensions intro page for more information.

### Hierarchy

- Tool
  - DraggingTool
    - GuidedDraggingTool

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

### Constructors

- constructor

### Properties

- centerGuidelineColor
- guidelineSnapDistance
- guidelineWidth
- horizontalGuidelineColor
- isGuidelineEnabled
- isGuidelineSnapEnabled
- searchDistance
- verticalGuidelineColor

### Methods

- clearGuidelines
- doDeactivate
- doDragOver
- doDropOnto
- invalidateLinks
- isGuiding
- showHorizontalMatches
- showVerticalMatches

## Constructors

### constructor

- new GuidedDraggingTool(): GuidedDraggingTool

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

  #### Returns GuidedDraggingTool

## Properties

### centerGuidelineColor : string

- Gets or sets the color of center guidelines.

  The default value is "gray".

### guidelineSnapDistance : number

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

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

### guidelineWidth : number

- Gets or sets the width guidelines.

  The default value is 1.

### horizontalGuidelineColor : string

- Gets or sets the color of horizontal guidelines.

  The default value is "gray".

### isGuidelineEnabled : boolean

- Gets or sets whether the guidelines are enabled or disable.

  The default value is true.

### isGuidelineSnapEnabled : boolean

- Gets or sets whether snapping to guidelines is enabled.

  The default value is true.

### searchDistance : number

- 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.

### verticalGuidelineColor : string

- Gets or sets the color of vertical guidelines.

  The default value is "gray".

## Methods

### clearGuidelines

- clearGuidelines(): void

- Removes all of the guidelines from the grid.

  #### Returns void

### Override doDeactivate

- doDeactivate(): void

- Calls the base method and removes the guidelines from the graph.

  #### Returns void

### Override doDragOver

- doDragOver(pt: Point, obj: GraphObject): void

- Shows vertical and horizontal guidelines for the dragged part.

  #### Parameters

  - ##### pt: Point

  - ##### obj: GraphObject

  #### Returns void

### Override doDropOnto

- doDropOnto(pt: Point, obj: GraphObject): void

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

  #### Parameters

  - ##### pt: Point

  - ##### obj: GraphObject

  #### Returns void

### invalidateLinks

- 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

  - ##### node: Part

  #### Returns void

### Protected isGuiding

- 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

- 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

- 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

Copyright © 1998-2021 by Northwoods Software Corporation.