Search code examples
hoverjointjs

How to change the color of a diagram cell while hovering?


I have an uml diagram and I want to change the color of one cell when the cursor is on it.

I tried to do it programmatically, but it doesn't work.

Here's my code:

paper.on('cell:mouseover', function(cellView, evt, x, y) { 
    var cell = graph.getCell(cellView.model.id)

    if (cell.isElement()) {
         cellView.model.attr({'uml-class-name-rect': { fill: '#33C3FF' }});
    } 
}

Solution

  • paper.on('cell:mouseenter', function(cellView) { 
          var cell = graph.getCell(cellView.model.id);
    
          if (cell.isElement()) {
            cellView.model.attr({'.uml-class-name-rect': { 'fill': '#33C3FF' }});
          }
        });
    

    CSS of class 'uml-class-name-rect' can't be set simultaneously through a global css file.