UNPKG

gojs

Version:

Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams

38 lines (37 loc) 1.9 kB
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Draggable Link Labels That Stay On Path</title> <meta name="description" content="TypeScript: This variation on the LinkLabelDraggingTool extension restricts link labels to stay on the link's route while the user is dragging it." /> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Copyright 1998-2019 by Northwoods Software Corporation. --> <script src="../samples/assets/require.js"></script> <script src="../assets/js/goSamples.js"></script> <!-- this is only for the GoJS Samples framework --> <script id="code"> function init() { require(["LinkLabelOnPathDraggingScript"], function(app) { app.init(); }); } </script> </head> <body onload="init()"> <div id="sample"> <div id="myDiagramDiv" style="background-color: whitesmoke; border: solid 1px black; width: 100%; height: 600px"></div> <p> This sample demonstrates a custom Tool, LinkLabelOnPathDraggingTool, that allows the user to drag the label of a Link, but that keeps the label exactly on the path of the link. The tool is defined at <a href="LinkLabelOnPathDraggingTool.ts">LinkLabelOnPathDraggingTool.ts</a>. </p> <p> The label on the link can be any arbitrarily complex object. It is positioned by the <a>GraphObject.segmentIndex</a> and <a>GraphObject.segmentFraction</a> properties, which are set by the LinkLabelOnPathDraggingTool. TwoWay Bindings on those two properties automatically remember any modified values on the link data object in the model. </p> <p> The tool is derived from a similar tool, <a href="LinkLabelDraggingTool.ts">LinkLabelDraggingTool.ts</a>, that allows the user to drag the label in any direction from the mid-point of the Link path. </p> </div> </body> </html>