antvis/G6

Do you want to work on this issue?
You can request for a bounty in order to promote it!
[Feat]: When dragging an element, don't default to the top layer, you want to have a config item that controls whether it needs to be placed at the top level #6999
leftiestor posted onGitHub
Describe the feature / 功能描述
拖拽元素时,不要默认将其置于顶层,希望有个配置项可以控制是否需要置于顶层
改造一下onDragStart方法:
/**
* <zh/> 拖拽开始时的回调
*
* <en/> Callback when dragging starts
* @param event - <zh/> 拖拽事件对象 | <en/> drag event object
* @internal
*/
protected onDragStart(event: IElementDragEvent) {
this.enable = this.validate(event);
if (!this.enable) return;
const { batch, canvas } = this.context;
canvas.setCursor(this.options!.cursor?.grabbing || 'grabbing');
this.isDragging = true;
batch!.startBatch();
this.target = this.getSelectedNodeIDs([event.target.id]);
this.hideEdge();
// 添加一个选项来决定是否置顶元素
if (this.options.frontElement) {
this.context.graph.frontElement(this.target);
}
if (this.options.shadow) this.createShadow(this.target);
}
Are you willing to contribute? / 是否愿意参与贡献?
✅ Yes / 是