src/js/widgets/sliderWidget.js
branchpopcorn-port
changeset 488 ab73470647cb
parent 481 a46cfeee6d77
child 731 e02f43299022
equal deleted inserted replaced
487:4c006b1dcc66 488:ab73470647cb
    45   this._Popcorn.listen("IriSP.PlayerWidget.MouseOut", IriSP.wrap(this, this.mouseOutHandler));
    45   this._Popcorn.listen("IriSP.PlayerWidget.MouseOut", IriSP.wrap(this, this.mouseOutHandler));
    46 };
    46 };
    47 
    47 
    48 /* update the slider and the position marker as time passes */
    48 /* update the slider and the position marker as time passes */
    49 IriSP.SliderWidget.prototype.sliderUpdater = function() {
    49 IriSP.SliderWidget.prototype.sliderUpdater = function() {
    50   if(this.draggingOngoing || this._disableUpdates)
    50   if(this.draggingOngoing || this._disableUpdate)
    51     return;
    51     return;
    52   
    52   
    53   var time = this._Popcorn.currentTime();
    53   var time = this._Popcorn.currentTime();
    54 
    54 
    55   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
    55   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
   142 // called when the user starts dragging the position indicator
   142 // called when the user starts dragging the position indicator
   143 IriSP.SliderWidget.prototype.positionMarkerDraggingStartedHandler = function(event, ui) {  
   143 IriSP.SliderWidget.prototype.positionMarkerDraggingStartedHandler = function(event, ui) {  
   144   this.draggingOngoing = true;
   144   this.draggingOngoing = true;
   145 };
   145 };
   146 
   146 
   147 IriSP.SliderWidget.prototype.positionMarkerDraggedHandler = function(event, ui) {
   147 IriSP.SliderWidget.prototype.positionMarkerDraggedHandler = function(event, ui) {   
   148   console.log(ui.offset.left);
       
   149   this._disableUpdate = true; // disable slider position updates while dragging is ongoing.
   148   this._disableUpdate = true; // disable slider position updates while dragging is ongoing.
   150   window.setTimeout(IriSP.wrap(this, function() { this._disableUpdate = false; }), 500);
   149   window.setTimeout(IriSP.wrap(this, function() { this._disableUpdate = false; }), 500);
   151   
   150 
       
   151   var parentOffset = this.sliderForeground.parent().offset();
   152   var width = this.sliderBackground.width();
   152   var width = this.sliderBackground.width();
       
   153   var relX = event.pageX - parentOffset.left;
       
   154 
   153   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
   155   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
   154   var newTime = ((ui.offset.left / width) * duration).toFixed(2);
   156   var newTime = ((relX / width) * duration).toFixed(2);
   155 
   157 
   156   this._Popcorn.currentTime(newTime);
   158   this._Popcorn.currentTime(newTime);
   157 
   159   
   158   this.draggingOngoing = false;
   160   this.draggingOngoing = false;
   159 };
   161 };
   160 
   162