From 94cc981af64e3a073c0bb0741edc2c91931ec7a3 Mon Sep 17 00:00:00 2001 From: Brian Tan Date: Fri, 1 Apr 2016 14:06:26 -0400 Subject: [PATCH] Fix slider bug when start is not 0 141: pctOfBar should take account of start value 278: value should have start offset. --- js/foundation.slider.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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;} -- 2.47.2