WIP - nearly fixed all the bugs with the sliceWidget.js. I still have got to popcorn-port
authorhamidouk
Fri, 20 Jan 2012 17:26:55 +0100
branchpopcorn-port
changeset 690 b7ac9cfefda4
parent 689 dfd601bd2ea8
child 691 2297203d7fa3
WIP - nearly fixed all the bugs with the sliceWidget.js. I still have got to replicate the code for the right handle.
src/js/widgets/sliceWidget.js
--- a/src/js/widgets/sliceWidget.js	Fri Jan 20 17:07:14 2012 +0100
+++ b/src/js/widgets/sliceWidget.js	Fri Jan 20 17:26:55 2012 +0100
@@ -70,31 +70,18 @@
   
   var currentX = this.leftHandle.position()["left"];
   var rightHandleX = Math.floor(this.rightHandle.position()["left"]);
-  //ui.position.left = Math.floor(ui.position.left);
   
-  if (currentX >= rightHandleX - 7 && ui.position.left >= this._leftHandleOldLeft) {
+  if (Math.floor(ui.position.left) >= rightHandleX - 7) {
     /* prevent the handle from moving past the right handle */
-    ui.position.left = this._leftHandleOldLeft;
+    ui.position.left = rightHandleX - 7;
   }
-  
-  if (ui.position.left > this._leftHandleOldLeft) {
-    console.log(ui.position.left, this._leftHandleOldLeft);
-    var increment = 1;
-  } else if (ui.position.left < this._leftHandleOldLeft)
-    var increment = -1;
-  else
-    var increment = 0;
-  
-  // the width of the zone is supposed to diminish by increment
-  // while at the same time the position of the zone should
-  // change by the opposite increment.
-  this.zoneWidth = this.zoneWidth - increment;
-  this.zoneLeft = Math.floor(this._leftHandleOldLeft + increment + 7);
+
+  this.zoneWidth = rightHandleX - Math.floor(ui.position.left) - 7;  
+  this.zoneLeft = Math.floor(ui.position.left) + 8;
   
   this.sliceZone.css("width", this.zoneWidth);
   this.sliceZone.css("left", this.zoneLeft + "px");
-  this._leftHandleOldLeft = Math.floor(this._leftHandleOldLeft + increment);
-  ui.position.left = this._leftHandleOldLeft;
+  this._leftHandleOldLeft = Math.floor(this._leftHandleOldLeft);  
   this.broadcastChanges();
     
 };