src/js/widgets/sliceWidget.js
branchpopcorn-port
changeset 691 2297203d7fa3
parent 690 b7ac9cfefda4
child 692 4eca4ee558a3
equal deleted inserted replaced
690:b7ac9cfefda4 691:2297203d7fa3
    69   */
    69   */
    70   
    70   
    71   var currentX = this.leftHandle.position()["left"];
    71   var currentX = this.leftHandle.position()["left"];
    72   var rightHandleX = Math.floor(this.rightHandle.position()["left"]);
    72   var rightHandleX = Math.floor(this.rightHandle.position()["left"]);
    73   
    73   
    74   if (Math.floor(ui.position.left) >= rightHandleX - 7) {
    74   if (Math.floor(ui.position.left) >= rightHandleX - 6) {
    75     /* prevent the handle from moving past the right handle */
    75     /* prevent the handle from moving past the right handle */
    76     ui.position.left = rightHandleX - 7;
    76     ui.position.left = rightHandleX - 6;
    77   }
    77   }
    78 
    78 
    79   this.zoneWidth = rightHandleX - Math.floor(ui.position.left) - 7;  
    79   this.zoneWidth = rightHandleX - Math.floor(ui.position.left) - 7;  
    80   this.zoneLeft = Math.floor(ui.position.left) + 8;
    80   this.zoneLeft = Math.floor(ui.position.left) + 8;
    81   
    81   
    86     
    86     
    87 };
    87 };
    88 
    88 
    89 /** handle a dragging of the right handle */
    89 /** handle a dragging of the right handle */
    90 IriSP.SliceWidget.prototype.rightHandleDragged = function(event, ui) { 
    90 IriSP.SliceWidget.prototype.rightHandleDragged = function(event, ui) { 
    91   var currentX = this.rightHandle.position()["left"];
    91   /* we have a special variable, this._leftHandleOldLeft, to keep the
    92   var leftHandleX = this.leftHandle.position()["left"];
    92      previous position of the handle. We do that to know in what direction
       
    93      is the handle being dragged
       
    94   */
    93   
    95   
    94   if (currentX <= leftHandleX + 7 && ui.position.left <= this._rightHandleOldLeft) {
    96   var currentX = this.leftHandle.position()["left"];
       
    97   var leftHandleX = Math.floor(this.leftHandle.position()["left"]);
       
    98   
       
    99   if (Math.floor(ui.position.left) < leftHandleX + 7) {
    95     /* prevent the handle from moving past the right handle */
   100     /* prevent the handle from moving past the right handle */
    96     ui.position.left = this._rightHandleOldLeft;
   101     ui.position.left = leftHandleX + 7;
    97   }
   102   }
       
   103 
       
   104   this.zoneWidth = Math.floor(ui.position.left) - (leftHandleX + 7);    
    98   
   105   
    99   var increment = currentX - (this.zoneLeft + this.zoneWidth);  
       
   100 
       
   101   this.zoneWidth += increment;  
       
   102   this.sliceZone.css("width", this.zoneWidth);
   106   this.sliceZone.css("width", this.zoneWidth);
       
   107   //this.sliceZone.css("left", this.zoneLeft + "px");
       
   108   this._rightHandleOldLeft = Math.floor(this._rightHandleOldLeft);  
   103   this.broadcastChanges();
   109   this.broadcastChanges();
   104   
       
   105   this._rightHandleOldLeft = ui.position.left; 
       
   106 };
   110 };
   107 
   111 
   108 /** tell to the world that the coordinates of the slice have
   112 /** tell to the world that the coordinates of the slice have
   109     changed 
   113     changed 
   110 */
   114 */