src/js/widgets/sliceWidget.js
branchpopcorn-port
changeset 691 2297203d7fa3
parent 690 b7ac9cfefda4
child 692 4eca4ee558a3
--- a/src/js/widgets/sliceWidget.js	Fri Jan 20 17:26:55 2012 +0100
+++ b/src/js/widgets/sliceWidget.js	Mon Jan 23 11:04:57 2012 +0100
@@ -71,9 +71,9 @@
   var currentX = this.leftHandle.position()["left"];
   var rightHandleX = Math.floor(this.rightHandle.position()["left"]);
   
-  if (Math.floor(ui.position.left) >= rightHandleX - 7) {
+  if (Math.floor(ui.position.left) >= rightHandleX - 6) {
     /* prevent the handle from moving past the right handle */
-    ui.position.left = rightHandleX - 7;
+    ui.position.left = rightHandleX - 6;
   }
 
   this.zoneWidth = rightHandleX - Math.floor(ui.position.left) - 7;  
@@ -88,21 +88,25 @@
 
 /** handle a dragging of the right handle */
 IriSP.SliceWidget.prototype.rightHandleDragged = function(event, ui) { 
-  var currentX = this.rightHandle.position()["left"];
-  var leftHandleX = this.leftHandle.position()["left"];
+  /* we have a special variable, this._leftHandleOldLeft, to keep the
+     previous position of the handle. We do that to know in what direction
+     is the handle being dragged
+  */
   
-  if (currentX <= leftHandleX + 7 && ui.position.left <= this._rightHandleOldLeft) {
-    /* prevent the handle from moving past the right handle */
-    ui.position.left = this._rightHandleOldLeft;
-  }
+  var currentX = this.leftHandle.position()["left"];
+  var leftHandleX = Math.floor(this.leftHandle.position()["left"]);
   
-  var increment = currentX - (this.zoneLeft + this.zoneWidth);  
+  if (Math.floor(ui.position.left) < leftHandleX + 7) {
+    /* prevent the handle from moving past the right handle */
+    ui.position.left = leftHandleX + 7;
+  }
 
-  this.zoneWidth += increment;  
+  this.zoneWidth = Math.floor(ui.position.left) - (leftHandleX + 7);    
+  
   this.sliceZone.css("width", this.zoneWidth);
+  //this.sliceZone.css("left", this.zoneLeft + "px");
+  this._rightHandleOldLeft = Math.floor(this._rightHandleOldLeft);  
   this.broadcastChanges();
-  
-  this._rightHandleOldLeft = ui.position.left; 
 };
 
 /** tell to the world that the coordinates of the slice have