-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot fire events with g6-react-node #3455
Comments
because of event triggers' least unit is the item, unless your mouse in or mouse out event are triggered with item(node), the shape in item won't trigger these event |
@mxz96102, thanks for your reply, could you provide an example how to subscribe on onMouseEnter correctly? |
quick fix;hijack import { createNodeFromReact as originCreateNodeFromReact } from '@antv/g6-react-node'
const cfg2EventMap = {
onClick: 'click',
onDBClick: 'dblclick',
onMouseEnter: 'mouseenter',
onMouseMove: 'mousemove',
onMouseOut: 'mouseout',
onMouseOver: 'mouseover',
onMouseLeave: 'mouseleave',
onMouseDown: 'mousedown',
onMouseUp: 'mouseup',
onDragStart: 'dragstart',
onDrag: 'drag',
onDragEnd: 'dragend',
onDragEnter: 'dragenter',
onDragLeave: 'dragleave',
onDragOver: 'dragover',
onDrop: 'drop',
onContextMenu: 'contextmenu',
}
export const createNodeFromReact = function (arg) {
const shapeOption = originCreateNodeFromReact(arg)
const originDraw = shapeOption.draw
shapeOption.draw = function (cfg: any, group: IGroup) {
const target = originDraw(cfg, group)
// 遍历
group.find((shape: any) => {
const cfgKeys = Object.keys(shape.cfg)
// 绑定相关事件
cfgKeys
.filter(key => cfg2EventMap[key])
.forEach(eventKey => {
shape.on(cfg2EventMap[eventKey], shape.cfg[eventKey])
})
return false
})
return target
}
return shapeOption
} |
This issue has been closed because it has been outdate for a long time. |
Describe the bug
Your Example Website or App
https://codesandbox.io/s/frosty-euclid-3zbt9?file=/index.js
Steps to Reproduce the Bug or Issue
Hover over element
Expected behavior
The onMouseOut event should be triggered
Screenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: