Konvajs Group 突出显示边框

Konvajs Group Highlight with Border

我有 2 个组,每个组内有圆形或矩形。我需要在单击时用边框突出显示该组,以便用户知道哪个组处于活动状态。

有很多方法可以做到这一点。例如:

group.on('click', () => {
  // toggle selected, this is just our custom property
  group.isSelected = !group.isSelected;
  // hide or show selection box
  selectionRect.visible(group.isSelected);
  // set box size and position
  selectionRect.setAttrs(group.getClientRect()); 
  layer.draw();
})

演示:http://jsbin.com/nucopakijo/1/edit?html,js,output