我没有使用Javascript,但是根据以前的编程经验,我只是有点迷失为什么总是在下面调用else语句:
function moveDiv(event) {
var x = event.clientX;
var $div = $("div"); // Used for velocity called in head of html
var currentPos = document.getElementById("div").style.left; // parse current position in div (set inline)
if (currentPos > x) {
$div.velocity({rotateZ:0, left:x+"px"},2000, "ease-in-out");
alert("CurrentPos is greater than x");
}
else {
$div.velocity({rotateZ:0, left:x+"px"},100, "ease-in-out"); // Always called
}
}