Merge pull request #117 from mayorovad/guides-fix

Fixed `Guides` story.
development
Thomas Bouffard 2022-10-09 20:05:29 +02:00 committed by GitHub
commit 4804767baf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -18,8 +18,7 @@ limitations under the License.
import {
Graph,
SelectionHandler,
InternalEvent,
constants,
eventUtils,
EdgeHandler,
EdgeStyle,
RubberBandHandler,
@ -47,12 +46,9 @@ const Template = ({ label, ...args }) => {
container.style.background = 'url(/images/grid.gif)';
container.style.cursor = 'default';
// Enables guides
SelectionHandler.prototype.guidesEnabled = true;
// Alt disables guides
SelectionHandler.prototype.useGuidesForEvent = function (me) {
return !InternalEvent.isAltDown(me.getEvent());
return !eventUtils.isAltDown(me.getEvent());
};
// Defines the guides to be red (default)
@ -69,6 +65,11 @@ const Template = ({ label, ...args }) => {
graph.setConnectable(true);
graph.gridSize = 30;
// Enables guides
const selectionHandler = graph.getPlugin('SelectionHandler');
if (selectionHandler)
selectionHandler.guidesEnabled = true;
// Changes the default style for edges "in-place" and assigns
// an alternate edge style which is applied in Graph.flip
// when the user double clicks on the adjustment control point