检索“快照到"使用jQuery UI的元素可拖动并启用快照 [英] Retrieving the "snapped to" element using jQuery UI draggable with snap enabled

查看:91
本文介绍了检索“快照到"使用jQuery UI的元素可拖动并启用快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery UI的可拖动对象,并启用了快照"并设置为选择一类元素.这意味着可拖动的对象会捕捉到(例如)名为 .general 的类的边缘.

I'm using jQuery UI's draggable, with 'snap' enabled and set to select a class of elements. This means that the draggable snaps to the edges of (for example) a class called .general.

当可拖动对象捕捉到类 .general 的元素时,是否可以找到或选择该捕捉到"的确切元素?

When the draggable is snapping to an element of class .general, is it possible to find or select that exact 'snapped to' element?

推荐答案

您可以尝试执行类似的操作,这将收获其捕捉到的元素:

You can try doing something like this, which will harvest the elements it is snapping to:

$( ".selector" ).draggable({
   stop: function(event, ui) {
            var snappedTo = $.map($(this).data('draggable').snapElements, function (element) {
                if (element.snapping) { return element; }
            });
   }
});

这篇关于检索“快照到"使用jQuery UI的元素可拖动并启用快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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