7

I am new to Cytoscape.js. I've managed to create a network. I'd like to change mouse cursor to pointer when mouse is over a node. Based on what I read, I should use the following code:

style: cytoscape.stylesheet()
    .selector('node')
      .css({
          'content': 'data(name)',
          'text-valign': 'center',
          'color': 'white',
          'text-outline-width': 2,
          'text-outline-color': '#888',          
          'cursor': 'pointer'
       })

//other code omitted

To my surprise, the cursor did not change. It stayed the same default cursor. What did I miss? Please help. Thanks.

4

4 回答 4

5
This worked for me :

cy.on('mouseover', 'node', function (evt) {                            
                        $('html,body').css('cursor', 'pointer');
                    } );

cy.on('mouseout', 'node', function (evt) {
                        $('html,body').css('cursor', 'default');
                    });
于 2016-04-07T10:00:49.023 回答
2

由于跨浏览器光标的技术问题以及光标根本不适用于触摸设备的事实,Cy.js 不再支持该cursor属性。

于 2013-10-28T19:58:12.060 回答
2
cy.on('mouseover', 'node', function(e){
    $('#diagram-wrapper').css('cursor', 'pointer');
});
cy.on('mouseout', 'node', function(e){
    $('#diagram-wrapper').css('cursor', 'default');
});

diagram-wrapper是一个包含 cytoscape.js 图的 div。

cy是 cytoscape js 对象

此代码$(document).ready(function() {...}cy.


感谢其他答案的启发。我不能完全让他们表现出来,所以这是我最终得到的混合体

于 2018-07-08T20:29:30.257 回答
2

使用 cytoscape 事件在包装 DOM 元素或画布本身上放置一个辅助类:

cys.on('mouseover', 'node', () => $(targetElement).addClass('mouseover'));
cys.on('mouseout', 'node', () => $(targetElement).removeClass('mouseover'));

然后在css中: .cysWrapper.mouseover { cursor: pointer; }

于 2015-09-04T14:07:52.200 回答