简体   繁体   English

带有可拖动帮助器的奇怪的可放置悬停效果

[英]Strange droppable Hover-Effect with draggable Helper

I'm testing around with jQuery draggables and droppables and have a question about the hover behaviour of droppable and clones of a draggable. 我正在测试jQuery draggables和droppables,并且对droppable和draggable的克隆的悬停行为有疑问。

The documentation says that the draggable item has to overlap the droppable at least 50% to fire the over-event (default tolerance). 该文档说,可拖动项必须与可放置项重叠至少50%,以触发事件过多(默认公差)。 This works exactly like described if I drag the item itself. 如果我拖动项目本身,它的工作原理与所描述的完全一样。

If I drag a clone of the item, the 50% rule doesn't work. 如果我拖动该项目的副本,则50%规则不起作用。 In this case the clone has to overlap the droppable quite 100% if I'm dragging vertically from the top. 在这种情况下,如果我从顶部垂直拖动,则克隆必须与可放置对象完全重叠100%。 If I'm dragging the clone from the left side, the hover-event will fire very early at 10%. 如果我从左侧拖动克隆,则悬停事件将在10%处提前触发。

How does this come up? 这是怎么出现的?

 $("#eins").draggable({ helper: "clone", opacity: 0.7, drag: function(event,ui) { $(ui.helper).addClass("clone") }, stop: function (event, ui) { console.log("Dragging stoped") } }) $("#zwei").droppable({ classes: {"ui-droppable-hover": "draggableHover"}, tolerance: "intersect", over: function(event, ui) { console.log("hover") }, drop: function (event, ui) { console.log("dropped") } }) 
 #eins, .clone { background: coral; height: 100px; width: 100px; margin: 0px; } #zwei { background:lightgreen; height:100px; width: 100px; margin: 0px; } .draggableHover { background: rgb(230, 250, 230) !important; } 
 <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script> <div id="eins"> eins </div> <div id="zwei"> zwei </div> 

解决方案:id =“ eins”的class =“ eins” intead。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM