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.
The LinkLabelDraggingTool class lets the user move a label on a Link.
Constructs a LinkLabelDraggingTool and sets the name for the tool.
The label being dragged.
This tool can only start if the mouse has moved enough so that it is not a click, and if the mouse down point is on a GraphObject "label" in a Link Panel, as determined by findLabel.
Restore the label's original value for GraphObject.segmentOffset.
Stop any ongoing transaction.
At the end of the drag, update the segment offset of the label and finish the tool, completing a transaction.
Clear any reference to a label element.
From the GraphObject at the mouse point, search up the visual tree until we get to an object that is a label of a Link.
This returns null if no such label is at the mouse down point.
Save the label's GraphObject.segmentOffset as a rotated offset from the midpoint of the Link that the label is in.