# HG changeset patch # User hamidouk # Date 1327680633 -3600 # Node ID d28b9acfc445c8ac22265505dfab32d56fdb4490 # Parent ccd571853e981e6436067166a66d8ade17888635 moved the sliderWidget from percents to pixels. It now has a satisfying display. diff -r ccd571853e98 -r d28b9acfc445 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"); };