Skip to content

Commit 7b0595a

Browse files
committed
Build for release
1 parent dee1026 commit 7b0595a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
Copyright (c) 2016-2021, The Cytoscape Consortium.
3+
Copyright (c) 2016-2021, 2023, The Cytoscape Consortium.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the “Software”), to deal in

cytoscape-cxtmenu.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ var cxtmenu = function cxtmenu(params) {
416416
var panEnabled = void 0;
417417
var boxEnabled = void 0;
418418
var gestureStartEvent = void 0;
419+
var hoverOn = void 0;
419420

420421
var restoreZoom = function restoreZoom() {
421422
if (zoomEnabled) {
@@ -626,7 +627,17 @@ var cxtmenu = function cxtmenu(params) {
626627
theta2 += dtheta;
627628
}
628629
queueDrawCommands(rx, ry, r, theta, rs);
629-
}).on('tapdrag', dragHandler).on('cxttapend tapend', function () {
630+
}).on('tapdrag', dragHandler).on('mousemove', function () {
631+
if (activeCommandI !== undefined) {
632+
var hovered = commands[activeCommandI].hover;
633+
if (hovered) {
634+
if (hoverOn !== activeCommandI) {
635+
hovered.apply(target, [target, gestureStartEvent]);
636+
}
637+
hoverOn = activeCommandI;
638+
}
639+
}
640+
}).on('cxttapend tapend', function () {
630641
parent.style.display = 'none';
631642
if (activeCommandI !== undefined) {
632643
var select = commands[activeCommandI].select;
@@ -637,6 +648,8 @@ var cxtmenu = function cxtmenu(params) {
637648
}
638649
}
639650

651+
hoverOn = undefined;
652+
640653
inGesture = false;
641654

642655
restoreGestures();
@@ -721,6 +734,9 @@ var defaults = {
721734
fillColor: 'rgba(200, 200, 200, 0.75)', // optional: custom background color for item
722735
content: 'a command name' // html/text content to be displayed in the menu
723736
contentStyle: {}, // css key:value pairs to set the command's css in js if you want
737+
hover: function(ele){ // a function to execute when the command is hovered
738+
console.log( ele.id() ) // `ele` holds the reference to the active element
739+
},
724740
select: function(ele){ // a function to execute when the command is selected
725741
console.log( ele.id() ) // `ele` holds the reference to the active element
726742
},

0 commit comments

Comments
 (0)