moved the sliderWidget from percents to pixels. It now has a satisfying display. popcorn-port
authorhamidouk
Fri, 27 Jan 2012 17:10:33 +0100
branchpopcorn-port
changeset 739 d28b9acfc445
parent 738 ccd571853e98
child 740 3b60f3beb521
moved the sliderWidget from percents to pixels. It now has a satisfying display.
src/js/widgets/sliderWidget.js
--- a/src/js/widgets/sliderWidget.js	Fri Jan 27 16:15:52 2012 +0100
+++ b/src/js/widgets/sliderWidget.js	Fri Jan 27 17:10:33 2012 +0100
@@ -53,26 +53,30 @@
   var time = this._Popcorn.currentTime();
 
   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
-  var percent = ((time / duration) * 100).toFixed(2);
+  var percents = time / duration;
   
   /* we do these complicated calculations to center exactly
      the position Marker */
-  var pixels_to_percents = 100 / this.selector.width(); /* how much is a pixel in percents */
+
+  var divWidth = this.selector.width();
+  var pixels = Math.floor(this.selector.width() * percents);
   var positionMarker_width = this.positionMarker.width();
-  var correction = (pixels_to_percents * positionMarker_width) / 2;
+  var correction = (positionMarker_width / 2);
 
   /* check that we don't leave the left side */
-  var newPos = percent - correction;
+  var newPos = pixels - correction;
   if (newPos <= 0)
     newPos = 0;
   
   /* check that we don't leave the right side */
-  var outPos = percent + correction;
-  if (outPos > 100)
-    newPos = 100;
+  var rightEdgePos = pixels + 1 * correction;
+
+  if (rightEdgePos >= divWidth)
+    newPos = divWidth - 1 * correction - 1;
   
-	this.sliderForeground.css("width", percent + "%");
-	this.positionMarker.css("left", newPos + "%");
+  console.log(newPos);
+	this.sliderForeground.css("width", pixels + "px");
+	this.positionMarker.css("left", newPos + "px");
 
 };