jquery可拖动和鼠标悬停 [英] jquery draggable and mouseover
问题描述
我目前有一些下拉菜单,可以在鼠标上打开。我正在使用jquery ui中的draggable和droppable来实现一些拖放功能。看来,当拖动菜单时,鼠标悬停事件不会触发,有没有办法让他们工作?
I currently have some dropdown menus which open on mouse over. I'm implementing some drag-n-drop features using draggable and droppable from jquery ui. It seems that the mouseover events for the menus do not fire when dragging, is there a way to allow them to work?
我已经实现了如下(简化) :
I've implemented it as follows (simplified):
$('#some_id').draggable({ helper: 'clone', opacity: 0.35, zIndex: 20000, cursor: 'move' });
$('#some_menu').live('mouseenter click', function(){jThis.find('div').addClass('opened');});
推荐答案
我刚刚发现这是一个非常合乎逻辑的问题。一旦你开始拖动元素,它就会粘在你的鼠标指针下面。因此,它只会将鼠标悬停在当前元素上。
I just found out that this is a very logical problem. Once you start dragging the element, it sticks under your mouse pointer.. hence, it'll just hover over the current element all the time!!
A(不是这样漂亮)修复是设置cursorAt选项,所以鼠标指针在draggable元素之外:
A (not so pretty) fix is to set the cursorAt option so the mouse pointer is outside of the draggable element:
$('#some_id').draggable({
cursorAt: {left: -10, top: -10}
});
如果有一种方式将鼠标指针传递到元素下方被拖动,但到目前为止,我还没有找到解决方案。
It would be much nicer if there is a way to somehow pass the mouse pointer underneath the element that is being dragged, but so far I haven't found a solution for that.
希望这有帮助!
这篇关于jquery可拖动和鼠标悬停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!