WIP - redoing the resize slice function. do not use. popcorn-port
authorhamidouk
Fri, 20 Jan 2012 17:07:14 +0100
branchpopcorn-port
changeset 689 dfd601bd2ea8
parent 688 76953dd536de
child 690 b7ac9cfefda4
WIP - redoing the resize slice function. do not use.
src/js/widgets/sliceWidget.js
--- a/src/js/widgets/sliceWidget.js	Fri Jan 20 17:06:49 2012 +0100
+++ b/src/js/widgets/sliceWidget.js	Fri Jan 20 17:07:14 2012 +0100
@@ -69,22 +69,34 @@
   */
   
   var currentX = this.leftHandle.position()["left"];
-  var rightHandleX = this.rightHandle.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) {
     /* prevent the handle from moving past the right handle */
     ui.position.left = this._leftHandleOldLeft;
   }
   
-  var increment = this.zoneLeft - (currentX + 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;
   
-  this.zoneWidth += increment;
-  this.zoneLeft = currentX + 7;
+  // 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.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.broadcastChanges();
-  
-  this._leftHandleOldLeft = ui.position.left;  
+    
 };
 
 /** handle a dragging of the right handle */