如何使jQuery draggable实际上捕捉到同样大小的droppable [英] How to make a jQuery draggable actually snap to an equally sized droppable

查看:94
本文介绍了如何使jQuery draggable实际上捕捉到同样大小的droppable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jquery-ui正确设置了可拖动和可放置的设置。它们都是相同的大小,因此可拖动的应该适合放置在droppable上。有没有办法让可拖动的按扣进入可放置的中间,以便完全覆盖它?似乎我使用snap:参数它只是捕捉到边缘,而不一定是在droppable的中间。

I have my draggable and droppable setup correctly using jquery-ui. They are both the same size, so the draggable should fit nicely on to the droppable. Is there any way to make the draggable snap in to the middle of the droppable so as to completely cover it? It seems if I use the snap: parameter it just snaps to the edges, and not necessarily to the middle of the droppable.

推荐答案

这不能完成工作,给予或取一个像素:

Would this not do the job, give or take a pixel:

    drop: function(event, ui) { 
    $(ui.draggable).offset($(this).offset());
    }

这篇关于如何使jQuery draggable实际上捕捉到同样大小的droppable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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