src/js/widgets/sliceWidget.js
branchpopcorn-port
changeset 690 b7ac9cfefda4
parent 689 dfd601bd2ea8
child 691 2297203d7fa3
equal deleted inserted replaced
689:dfd601bd2ea8 690:b7ac9cfefda4
    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 = Math.floor(this.rightHandle.position()["left"]);
    72   var rightHandleX = Math.floor(this.rightHandle.position()["left"]);
    73   //ui.position.left = Math.floor(ui.position.left);
       
    74   
    73   
    75   if (currentX >= rightHandleX - 7 && ui.position.left >= this._leftHandleOldLeft) {
    74   if (Math.floor(ui.position.left) >= rightHandleX - 7) {
    76     /* prevent the handle from moving past the right handle */
    75     /* prevent the handle from moving past the right handle */
    77     ui.position.left = this._leftHandleOldLeft;
    76     ui.position.left = rightHandleX - 7;
    78   }
    77   }
    79   
    78 
    80   if (ui.position.left > this._leftHandleOldLeft) {
    79   this.zoneWidth = rightHandleX - Math.floor(ui.position.left) - 7;  
    81     console.log(ui.position.left, this._leftHandleOldLeft);
    80   this.zoneLeft = Math.floor(ui.position.left) + 8;
    82     var increment = 1;
       
    83   } else if (ui.position.left < this._leftHandleOldLeft)
       
    84     var increment = -1;
       
    85   else
       
    86     var increment = 0;
       
    87   
       
    88   // the width of the zone is supposed to diminish by increment
       
    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   
    81   
    94   this.sliceZone.css("width", this.zoneWidth);
    82   this.sliceZone.css("width", this.zoneWidth);
    95   this.sliceZone.css("left", this.zoneLeft + "px");
    83   this.sliceZone.css("left", this.zoneLeft + "px");
    96   this._leftHandleOldLeft = Math.floor(this._leftHandleOldLeft + increment);
    84   this._leftHandleOldLeft = Math.floor(this._leftHandleOldLeft);  
    97   ui.position.left = this._leftHandleOldLeft;
       
    98   this.broadcastChanges();
    85   this.broadcastChanges();
    99     
    86     
   100 };
    87 };
   101 
    88 
   102 /** handle a dragging of the right handle */
    89 /** handle a dragging of the right handle */