do some boundaries checks. popcorn-port
authorhamidouk
Fri, 27 Jan 2012 15:34:15 +0100
branchpopcorn-port
changeset 731 e02f43299022
parent 730 357fc047503b
child 732 823fa16807d4
do some boundaries checks.
src/js/widgets/sliderWidget.js
--- a/src/js/widgets/sliderWidget.js	Fri Jan 27 12:06:04 2012 +0100
+++ b/src/js/widgets/sliderWidget.js	Fri Jan 27 15:34:15 2012 +0100
@@ -61,10 +61,16 @@
   var positionMarker_width = this.positionMarker.width();
   var correction = (pixels_to_percents * positionMarker_width) / 2;
 
+  /* check that we don't leave the left side */
   var newPos = percent - correction;
   if (newPos <= 0)
     newPos = 0;
   
+  /* check that we don't leave the right side */
+  var outPos = percent + correction;
+  if (outPos > 100)
+    newPos = 100;
+  
 	this.sliderForeground.css("width", percent + "%");
 	this.positionMarker.css("left", newPos + "%");