Repository navigation
[Bug]: 仅启用drag-canvas禁用drag-element时,点击到node节点时无法触发drag-canvas行为 #7407
Unanswered
bertonwalker-cn
asked this question in
Q&A
Replies: 3 comments 1 reply
|
@bertonwalker-cn 您好!以下是关于您问题的自动回复: 感谢您的反馈和详细描述! 问题分析在 G6 v5.x 中, 如果未启用 目前的行为是设计如此
解决建议
示例:自定义 drag-canvas 行为(简易版) import { Graph, registerBehavior } from '@antv/g6';
// 注册自定义行为
registerBehavior('custom-drag-canvas', {
getEvents() {
return {
'mousedown': 'onMouseDown',
'mousemove': 'onMouseMove',
'mouseup': 'onMouseUp',
};
},
onMouseDown(e) {
this.origin = { x: e.x, y: e.y };
this.dragging = true;
},
onMouseMove(e) {
if (this.dragging) {
const dx = e.x - this.origin.x;
const dy = e.y - this.origin.y;
this.graph.translate(dx, dy);
this.origin = { x: e.x, y: e.y };
}
},
onMouseUp() {
this.dragging = false;
}
});
// 使用自定义行为
const graph = new Graph({
// ... 其它配置
behaviors: [
{ type: 'custom-drag-canvas' }
],
});
总结如需进一步帮助或有其他需求,欢迎补充说明! 此回复由 AI 助手自动生成。如有任何问题,我们的团队会尽快跟进。 |
0 replies
配置到哪里? |
0 replies
|
|
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug / 问题描述
const graph = new G6.Graph({
container: 'container',
width: 800,
height: 600,
behaviors: [
{
type: 'drag-canvas',
enable: (event) => true, // 不管点在什么上,都允许拖动画布
},
],
});
Reproduction link / 复现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
No response
Version / 版本
🆕 5.x
OS / 操作系统
Browser / 浏览器
All reactions