简体   繁体   English

仅当作为#div1子级的div超过#div2时,将#div1(可拖动)放入#div2(可拖放)

[英]Drop #div1 (draggable) into #div2 (droppable) only when a div that is a child of #div1 is over #div2

I try to drop a div into another one, using his child as the area that should activate the droppable. 我尝试将div放入另一个div中,使用他的孩子作为应该激活可放置对象的区域。

To make things more clear let's say that we have #parent_div, #child_div and #droppable. 为了使事情更清楚,我们假设我们有#parent_div,#child_div和#droppable。 I want to drag #parent_div over #droppable, but be able to drop it only when the smaller div (#child_div) inside it is over #droppable. 我想将#parent_div拖放到#droppable上,但是仅当其中较小的div(#child_div)超过#droppable时才可以将其拖放。

Is this possible using jQuery UI? 使用jQuery UI有可能吗?

Thanks 谢谢

"out of the box" I do not think this is possible. 我认为“开箱即用”是不可能的。 Look at the tolerance option. 查看公差选项。 This is the extent of how you can define when the dragged item is over a target. 这是如何定义所拖动项目在目标上方的程度。 "fit" or "intersect" might get you close to what you want, but not quite there. “适合”或“相交”可能使您接近想要的东西,但并不完全到此为止。

To get what you want would require patching in a custom tolerance option. 要获得所需的内容,需要在自定义公差选项中打补丁。 Or just implementing your own drag&drop. 或者只是实现自己的拖放。

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

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