]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Fix slider bug when start is not 0 8506/head
authorBrian Tan <briantan888@users.noreply.github.com>
Fri, 1 Apr 2016 18:06:26 +0000 (14:06 -0400)
committerBrian Tan <briantan888@users.noreply.github.com>
Fri, 1 Apr 2016 18:06:26 +0000 (14:06 -0400)
141: pctOfBar should take account of start value
278: value should have start offset.

js/foundation.slider.js

index 71c7a91b9caeb20bbcf5f6c8d0f1c4a694415e24..673c17a04c23782f4c6b4d716eff9772d2605f48 100644 (file)
@@ -138,7 +138,7 @@ class Slider {
         handleDim = $hndl[0].getBoundingClientRect()[hOrW],
         elemDim = this.$element[0].getBoundingClientRect()[hOrW],
         //percentage of bar min/max value based on click or drag point
-        pctOfBar = percent(location, this.options.end).toFixed(2),
+        pctOfBar = percent(location - this.options.start, this.options.end - this.options.start).toFixed(2),
         //number of actual pixels to shift the handle, based on the percentage obtained above
         pxToMove = (elemDim - handleDim) * pctOfBar,
         //percentage of bar to shift the handle
@@ -275,7 +275,7 @@ class Slider {
           //if the cursor position is less than or greater than the elements bounding coordinates, set coordinates within those bounds
           barXY = barOffset > 0 ? -halfOfHandle : (barOffset - halfOfHandle) < -barDim ? barDim : Math.abs(barOffset),
           offsetPct = percent(barXY, barDim);
-      value = (this.options.end - this.options.start) * offsetPct;
+      value = (this.options.end - this.options.start) * offsetPct + this.options.start;
 
       // turn everything around for RTL, yay math!
       if (Foundation.rtl() && !this.options.vertical) {value = this.options.end - value;}