src/js/widgets/sliceWidget.js
branchpopcorn-port
changeset 689 dfd601bd2ea8
parent 619 2abc7d900f5e
child 690 b7ac9cfefda4
equal deleted inserted replaced
688:76953dd536de 689:dfd601bd2ea8
    67      previous position of the handle. We do that to know in what direction
    67      previous position of the handle. We do that to know in what direction
    68      is the handle being dragged
    68      is the handle being dragged
    69   */
    69   */
    70   
    70   
    71   var currentX = this.leftHandle.position()["left"];
    71   var currentX = this.leftHandle.position()["left"];
    72   var rightHandleX = this.rightHandle.position()["left"];
    72   var rightHandleX = Math.floor(this.rightHandle.position()["left"]);
       
    73   //ui.position.left = Math.floor(ui.position.left);
    73   
    74   
    74   if (currentX >= rightHandleX - 7 && ui.position.left >= this._leftHandleOldLeft) {
    75   if (currentX >= rightHandleX - 7 && ui.position.left >= this._leftHandleOldLeft) {
    75     /* prevent the handle from moving past the right handle */
    76     /* prevent the handle from moving past the right handle */
    76     ui.position.left = this._leftHandleOldLeft;
    77     ui.position.left = this._leftHandleOldLeft;
    77   }
    78   }
    78   
    79   
    79   var increment = this.zoneLeft - (currentX + 7);
    80   if (ui.position.left > this._leftHandleOldLeft) {
       
    81     console.log(ui.position.left, this._leftHandleOldLeft);
       
    82     var increment = 1;
       
    83   } else if (ui.position.left < this._leftHandleOldLeft)
       
    84     var increment = -1;
       
    85   else
       
    86     var increment = 0;
    80   
    87   
    81   this.zoneWidth += increment;
    88   // the width of the zone is supposed to diminish by increment
    82   this.zoneLeft = currentX + 7;
    89   // while at the same time the position of the zone should
       
    90   // change by the opposite increment.
       
    91   this.zoneWidth = this.zoneWidth - increment;
       
    92   this.zoneLeft = Math.floor(this._leftHandleOldLeft + increment + 7);
       
    93   
    83   this.sliceZone.css("width", this.zoneWidth);
    94   this.sliceZone.css("width", this.zoneWidth);
    84   this.sliceZone.css("left", this.zoneLeft + "px");
    95   this.sliceZone.css("left", this.zoneLeft + "px");
       
    96   this._leftHandleOldLeft = Math.floor(this._leftHandleOldLeft + increment);
       
    97   ui.position.left = this._leftHandleOldLeft;
    85   this.broadcastChanges();
    98   this.broadcastChanges();
    86   
    99     
    87   this._leftHandleOldLeft = ui.position.left;  
       
    88 };
   100 };
    89 
   101 
    90 /** handle a dragging of the right handle */
   102 /** handle a dragging of the right handle */
    91 IriSP.SliceWidget.prototype.rightHandleDragged = function(event, ui) { 
   103 IriSP.SliceWidget.prototype.rightHandleDragged = function(event, ui) { 
    92   var currentX = this.rightHandle.position()["left"];
   104   var currentX = this.rightHandle.position()["left"];