G6
G6 copied to clipboard
如果节点定义的style里面包含如 lineDash这种如果value为object的样式属性之后,变更stateStyles 后这个样式不能还原。lineDash:[10,5]
- [ ] I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
Steps to reproduce
自定义node
...
style: {
lineDash: [10,5]
},
stateStyles: {
activited: {
opacity: 0.7,
strokeOpacity: 0.7
}
}
...
改变state
...
this.graph.on('node:mouseenter', e => {
this.graph.setItemState(e.item, 'activited', true)
})
...
清除state
...
this.graph.on('node:mouseleave', e => {
this.graph.clearItemStates(e.item, ['activited'])
})
...
结果
状态清除了,但是lineDash 这个样式没有生效
原因
查看了一下源代码,在shapeBase.js文件 setState
方法出现问题, 如下链接
https://github.com/antvis/G6/blob/6ff409a3a84f6ea0c18d2ee340b5721bb24f066d/packages/core/src/element/shapeBase.ts#L493
Environment | Info |
---|---|
g6 | 4.3.8 |
System | - |
Browser | - |
请提供一下在线复现 demo 呢?我在官网没能复现
同样的问题,如果在在定义节点的setState中,用了item.attr()来设置样式,改变了状态后,状态清除了但是样式依然在
该问题在当前版本中已不存在。回复 lineDash: undefined 可以将虚线恢复直线