iVis-at-Bilkent / cytoscape.js-context-menus

A Cytoscape.js extension to provide context menu around elements and core instance
MIT License
86 stars 41 forks source link

Problem with changing options #37

Closed Hoogkamer closed 4 years ago

Hoogkamer commented 4 years ago

Hi, I want to be able to switch between a desktop-friendly and a mobile-friendly menu.

But when I recall cy.contextMenus(options) with new options it does not seem to work correctly anymore:

Example, when I add this to demo.html after line 190

cy.contextMenus({
          menuItems: [
            {
              id: "removeNew",
              content: "remove NEW",
              tooltipText: "remove",
              image: { src: "remove.svg", width: 12, height: 12, x: 6, y: 4 },
              selector: "node, edge",
              onClickFunction: function(event) {
                var target = event.target || event.cyTarget;
                target.remove();
              },
              hasTrailingDivider: true
            },
            {
              id: "select-all-edges",
              content: "select all edges NEW",
              tooltipText: "select all edges",
              selector: "edge",
              onClickFunction: function(event) {
                selectAllOfTheSameType(event.target || event.cyTarget);
              }
            }
          ]
        });

I get this when I click on Kramer (or any other element)

image

hasanbalci commented 4 years ago

@Hoogkamer Does this issue occur in desktop or in mobile? I can't reproduce it in desktop. When I tried your example it works correctly. You can see it here.

Hoogkamer commented 4 years ago

You are right. I tested this by mistake with my local changed version in stead of the original. I tried to implement the option for taphold, but did it wrong.

Now it works, I will create a new PR for the proper taphold option.

Thanks for looking into this.