From: Brian Tan Date: Fri, 1 Apr 2016 18:06:26 +0000 (-0400) Subject: Fix slider bug when start is not 0 X-Git-Tag: v6.2.1~25^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8506%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Fix slider bug when start is not 0 141: pctOfBar should take account of start value 278: value should have start offset. --- diff --git a/js/foundation.slider.js b/js/foundation.slider.js index 71c7a91b9..673c17a04 100644 --- a/js/foundation.slider.js +++ b/js/foundation.slider.js @@ -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;}