如何完全禁用元素事件? [英] How to totally disable elements events?

查看:40
本文介绍了如何完全禁用元素事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用化合物模型和cytoscape-compound拖放扩展,通过将一些节点分组在一起并轻松移动整个组,使用户可以手动重新组织布局.

I'm using the compound model and the cytoscape-compound-drag-and-drop extension to let the user manually reorganize the layout by grouping some nodes together and moving whole groups easily.

现在,我想要一个按钮来切换这些组框"的显示,但是继续显示所有非父节点.我首先在父节点上尝试了hide(),但同时也隐藏了子节点,因此我切换到动态应用指定display:hidden的类.
似乎可以解决问题,但仍然可以单击隐藏框,并应用cytoscape默认的视觉反馈"进行单击,以显示隐藏框仍位于的区域.

Now I want a button to toggle the display of these groups "boxes", but keep displaying all non-parent nodes. I first tried hide() on parent nodes, but it also hides the children, so I switched to dynamically applying a class which specifies display:hidden.
It seemed to do the trick, but still the hidden box can be clicked and cytoscape default "visual feedback" for click applies, showing off the area where the hidden box still lies.

我尝试了很多不起作用的事情:
-从我的隐藏样式类中禁用事件:尝试过的事件:否.我应该将其报告为错误吗?
-.ungrabify().unselectify().panify().lock()
-单击:销毁事件对象
-设置e.target._private.active = false

I tried plenty of things that didn't work:
- disable events from my hidden style class: tried events:no. Should I report this as a bug ?
- .ungrabify().unselectify().panify().lock()
- on click: destroy the event object
- set e.target._private.active = false

我尝试了一个讨厌的hack:设置e.target._private.position = {}该事件仍然被触发,但破坏位置成功阻止了视觉反馈"的发生,我的盒子实际上保持为隐藏"状态.但是,该事件仍然发生在错误的目标上:盒子上,而不是在cytoscape容器的空白处.我可以继续黑客攻击,然后再离开,但是没有更简单的解决方案吗?

I tried a nasty hack: setting e.target._private.position = {} The event is still fired, but destroying the position sucessfully prevents the "visual feedback" from happenning, my box effectively stays "hidden". But still the event occurs on the wrong target: the box, not on the empty space of the cytoscape container. I can keep hacking and leave with it, but isn't there a simpler solution to ?

是否可以简单真实地传递隐藏的父节点事件?

推荐答案

您没有正确使用事件.

cy.$('node').forEach(node => {
    node.events = 'no'; // will not work
});

以下方法确实有效,并且您还可以随时恢复事件.

The following does work, and you can also restore events whenever you want.

cy.$('node').forEach(node => {
    node.style('events', 'no');
});

这篇关于如何完全禁用元素事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆