我正在尝试选择一个选择手柄,然后移动它,但鼠标手柄与鼠标指针不同步。
当您选择矩形然后尝试移动中间选择手柄以在矩形中创建间隙时,鼠标指针远离手柄。
小提琴是: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;