Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
您可以尝试 jquery-collision 加上 jquery-ui-draggable-collision。 全面披露:我刚刚在 sourceforge 上编写并发布了这些内容。
第一个允许这样做:
这是与“#collider”重叠的所有“.obstacle”的列表。
第二个允许:
它为您提供(除其他外)一个要绑定的“碰撞”事件:
您甚至可以设置:
以防止“#collider”在拖动时与任何“.obstacle”重叠。
You can try jquery-collision plus jquery-ui-draggable-collision. Full disclosure: I just wrote and released these on sourceforge.
The first allows this:
which is the list of all ".obstacle" that overlap "#collider".
The second allows:
Which gives you (among other things), a "collision" event to bind to:
And you can even set:
to prevent "#collider" from ever overlapping any ".obstacle" while dragging.
快速搜索 jQuery 插件出现:
Collidable Draggables
看起来还为时过早,但可能值得退房。
Quick search of jQuery plugins turns up:
Collidable Draggables
Looks like it's still early, but might be worth checking out.
我知道这个问题已经很老了,但也许您会发现这很有用:我们的 jQuery 碰撞检查插件。
描述是德语的,但应该是不言自明的。 您可以使用两个单个元素甚至元素集,并且将返回一组所有冲突元素。
I know this question is quite old, but maybe you will find this useful: our Collision Check Plugin for jQuery.
The description is in German, but it should be self-explanatory. You can either use two single elements or even sets of elements and will get back a set of all colliding elements.
Google 告诉我,gameQuery(一个 JQuery 插件)具有“碰撞”功能:
http://gamequery.onaluf。 org/#manual
在上面的页面上搜索“碰撞”一词。
此谷歌搜索可以为您提供一些其他选项:
http://www. google.com/search?q=jquery+collision+detection
Google tells me that gameQuery, a JQuery plugin, has a "collision" function:
http://gamequery.onaluf.org/#manual
Search for the word "collision" on the page above.
This google search can give you a couple of other options:
http://www.google.com/search?q=jquery+collision+detection
假设,但我认为您需要的可以在这里找到:
$.event.special。 drop
它使用jQuery著名的$.event.special.drag来创建de drop事件。 您可以将自己的 javascript 代码放在
.bind( "drop", function( 事件 ){
该函数内的 this 元素代表您定义的“drop”类的对象,而 event.dragTarget 是正在拖动的对象。
上面链接的网站上有更多文档。 无论如何,这就是我所需要的。
Assuming, but I think what you would need can be found here:
$.event.special.drop
It uses the jQuery famous $.event.special.drag to create de drop event. You can put your own javascript code under the
.bind( "drop", function( event ){
the this element inside this function represent the object with the class "drop" you have defined and the event.dragTarget is the object that is being dragged.
More doc at the site linked above. This was what I needed anyway.