我想选择一个选择手柄,然后移动它,但鼠标手柄不在鼠标指针同步。
当您选择矩形,然后尝试移动中间的选择手柄,以创建在鼠标指针放在远离手柄是长方形的空隙。
小提琴是: http://jsfiddle.net/3PwWY/
case 8:
if(mx > mySel.x + mySel.w/2)
mySel.windowWidth = mx - (mySel.x + mySel.w/2);
else
mySel.windowWidth = (mySel.x + mySel.w/2) - mx;
// Enforce limits on mx:
// Should not be closer than 5 pixels to this.x (left side of metric box)
// Should not be > this.x + width/2 (middle of metric box)
if(mySel.windowWidth < 2* minGold)
mySel.windowWidth = 2* minGold;
console.log(mySel.windowWidth);
break;
case 9:
if(mx > mySel.x + mySel.w/2)
mySel.windowWidth = mx - (mySel.x + mySel.w/2);
else
mySel.windowWidth = (mySel.x + mySel.w/2) - mx;
// Enforce limits on mx:
// Should not be closer than 5 pixels to this.x (left side of metric box)
// Should not be > this.x + width/2 (middle of metric box)
// mySel.windowWidth = mx - (mySel.x + mySel.w/2);
console.log(mySel.windowWidth);
break;