【发布时间】:2009-03-19 19:24:21
【问题描述】:
我使用以下 javascript(带有 jQuery)来处理我正在编写的脚本上的拖放:
jsc.ui.dragging = false;
jsc.ui.drag_element = {};
$(".drag-target").mousedown(function() {
jsc.ui.drag_element = $(this);
jsc.ui.dragging = true;
});
$("html").mousemove(function(e) {
if(jsc.ui.dragging) {
jsc.ui.drag_element.css({"position": "absolute", "top": e.clientY - 1, "left": e.clientX - 1, "z-index": "100"}); // - 1s are due to IE not leaving go otherwise
$("#overlay").show(); // Overlay stops text beneath being selected. TODO Stop current elements text being selected.
}
});
$(".drag-target").mouseup(function() {
if(jsc.ui.dragging) {
jsc.ui.dragging = false;
jsc.ui.drag_element.css("z-index", "98");
$("#overlay").hide();
}
});
但是,当对象被拖动时,其中的文本会出现闪烁的选择,即在移动元素时打开和关闭它。有什么办法可以防止这种情况发生,或者隐藏它的影响吗?
【问题讨论】:
标签: javascript jquery drag-and-drop