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; |
56 var percent = ((time / duration) * 100).toFixed(2); |
56 var percents = time / duration; |
57 |
57 |
58 /* we do these complicated calculations to center exactly |
58 /* we do these complicated calculations to center exactly |
59 the position Marker */ |
59 the position Marker */ |
60 var pixels_to_percents = 100 / this.selector.width(); /* how much is a pixel in percents */ |
60 |
|
61 var divWidth = this.selector.width(); |
|
62 var pixels = Math.floor(this.selector.width() * percents); |
61 var positionMarker_width = this.positionMarker.width(); |
63 var positionMarker_width = this.positionMarker.width(); |
62 var correction = (pixels_to_percents * positionMarker_width) / 2; |
64 var correction = (positionMarker_width / 2); |
63 |
65 |
64 /* check that we don't leave the left side */ |
66 /* check that we don't leave the left side */ |
65 var newPos = percent - correction; |
67 var newPos = pixels - correction; |
66 if (newPos <= 0) |
68 if (newPos <= 0) |
67 newPos = 0; |
69 newPos = 0; |
68 |
70 |
69 /* check that we don't leave the right side */ |
71 /* check that we don't leave the right side */ |
70 var outPos = percent + correction; |
72 var rightEdgePos = pixels + 1 * correction; |
71 if (outPos > 100) |
73 |
72 newPos = 100; |
74 if (rightEdgePos >= divWidth) |
|
75 newPos = divWidth - 1 * correction - 1; |
73 |
76 |
74 this.sliderForeground.css("width", percent + "%"); |
77 console.log(newPos); |
75 this.positionMarker.css("left", newPos + "%"); |
78 this.sliderForeground.css("width", pixels + "px"); |
|
79 this.positionMarker.css("left", newPos + "px"); |
76 |
80 |
77 }; |
81 }; |
78 |
82 |
79 IriSP.SliderWidget.prototype.backgroundClickHandler = function(event) { |
83 IriSP.SliderWidget.prototype.backgroundClickHandler = function(event) { |
80 /* this piece of code is a little bit convoluted - here's how it works : |
84 /* this piece of code is a little bit convoluted - here's how it works : |