我希望 cursor 位于 center ui.helper of draggable 。
我是这样做的
$(".soclass").draggable({
cursor: "move",
helper: 'clone',
revert: "invalid",
tolerance: "fit",
start: function(event, ui){
$(this).draggable("option", "cursorAt", {
left: Math.floor(ui.helper.width() / 2),
top: Math.floor(ui.helper.height() / 2)
});
}
});
Using this i get cursor in the center only after First drop. How can I center align the cursor right from first drop.
最佳答案
您可以访问可拖动实例的 offset.click 属性,这几乎就是将光标设置为选项所做的设置选项的问题,正如您所描述的那样仅在您下次触发 start 事件时应用。但是使用该属性,您可以在当前事件上设置它。像这样:
start: function(event, ui){
$(this).draggable('instance').offset.click = {
left: Math.floor(ui.helper.width() / 2),
top: Math.floor(ui.helper.height() / 2)
};
}
关于jquery - 在 jquery-ui 可拖动方法中使 ui.helper 的光标位置在中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34827181/