Make sure there is always 1 pixel in slider if we are not at absolute top/bottom
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 24 Aug 2009 03:07:06 +0000 (21:07 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 24 Aug 2009 03:07:06 +0000 (21:07 -0600)
imp/js/DimpSlider.js

index ae30b8c..6b30e35 100644 (file)
@@ -193,9 +193,22 @@ var DimpSlider = Class.create({
         this.value = (type == 'val')
             ? Math.min(Math.max(0, data), this.options.totalsize - this.options.pagesize)
             : Math.max(0, Math.round(Math.min(data, this.handletop) / this.handletop * (this.options.totalsize - this.options.pagesize)));
-        this.handlevalue = (type == 'px')
-            ? data
-            : Math.round(this.getValue() / (this.options.totalsize - this.options.pagesize) * this.handletop);
+
+        if (type == 'px') {
+            this.handlevalue = data;
+        } else {
+            this.handlevalue = Math.round(this.value / (this.options.totalsize - this.options.pagesize) * this.handletop);
+
+            /* Always make sure there is at least 1 pixel if we are not at the
+             * absolute bottom or top. */
+            if (this.handlevalue == 0 && this.value != 0) {
+                this.handlevalue += 1;
+            } else if (this.handlevalue == this.handletop &&
+                       ((this.options.totalsize - this.options.pagesize) != this.value)) {
+                this.handlevalue -= 1;
+            }
+        }
+
         this.handle.setStyle({ top: this.handlevalue + 'px' });
     },