问题描述
我目前正在尝试在将Cytoscape.js嵌入到我的应用程序中实现以下行为:我希望当抓取复合节点的特定子节点时,抓取整个复合节点。
如果尝试使用此代码,但无法按我预期的那样工作:
I'm currently trying to implement the developp the following behavior in my application embedding Cytoscape.js : I would like that when a particular child node of a compound node is grabbed, the whole compound node is grabbed.
If tried using this code but it does not work as I expect :
cy.$(mySubNodeSelector)
.on('grab', function(){
this.ungrabify();
this.parent().select();
this.parent().grabify();
});
有人对如何实现此行为有建议吗?
非常感谢。
Does anybody has an advice about how to implement this behavior ?Thanks a lot.
推荐答案
在子项上禁用事件:
您的代码没有执行任何操作,因为(1 ),您将在元素被抓取后改变抓取能力,(二)将抓取(允许抓取)与抓取(用户手势)混合使用。
Your code doesn't do anything because (1) you're mutating grabbability after elements have been grabbed and (2) you conflate grabifying (allowing grabbing) with grabbing (a user gesture).
这篇关于抓取子节点时抓取复合节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!