插上時,我已根據關的旋轉木馬:禁用懸停,文本選擇等拖在JQuery中的元素
http://nooshu.com/explore/jquery-iphone-animation/
當你在抓取和拖動的過程中,你容易選擇文本。如果我有面板中的鏈接,我會得到懸停信息等等。
我想禁用所有這些,因此當您在拖動過程中,其餘交互功能被禁用。
想法?
插上時,我已根據關的旋轉木馬:禁用懸停,文本選擇等拖在JQuery中的元素
http://nooshu.com/explore/jquery-iphone-animation/
當你在抓取和拖動的過程中,你容易選擇文本。如果我有面板中的鏈接,我會得到懸停信息等等。
我想禁用所有這些,因此當您在拖動過程中,其餘交互功能被禁用。
想法?
創建一個樣式類是這樣的:
.unselectable {
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
-ms-user-select : none
}
然後更改JavaScript稍微對鼠標按下分配這個類。所以從這個不變的腳本看起來就像這樣。
jQuery(function($){
//Initialise
iPhoneAnimation.init();
//Mouse down bind move event
$(".content-box").bind("mousedown", function(e){
$(this).bind("mousemove", iPhoneAnimation.moveInfo);
$(this).addClass("unselectable"); // <-- ADD THIS
});
//Unbind mouse event
$(".content-box").bind("mouseup", function(e){
var $this = $(this);
$this.unbind("mousemove", iPhoneAnimation.moveInfo);
//Animate the panel
iPhoneAnimation.panelAnimate($this);
//Reset the private var
iPhoneAnimation.resetVars();
$(this).removeClass("unselectable"); // <-- AND ADD THIS
});
});
禁用徘徊,你需要解除綁定的mousedown
這樣的事件:
$(this).unbind('mouseenter mouseleave');
然後再重新綁定他們mouseup
如上。
document.onmousemove = function(ev)
{
ev.preventDefault();
/*
move it
*/
}
這對我有效,謝謝! –
我將完成Icchanobot的回答多一個行:
-ms-user-select : none
,使其與Internet Explorer上工作11/-
也做到了,謝謝! – Wesley