From 061d3b17b01bb605227344f2ee805de5c963da50 Mon Sep 17 00:00:00 2001 From: Burtchen Date: Fri, 10 Jul 2015 22:58:55 +0200 Subject: [PATCH] slider: add support for changing a value by clicking on the slider without having started to drag from the handle --- js/foundation/foundation.slider.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/foundation/foundation.slider.js b/js/foundation/foundation.slider.js index 23098250e..87f7a3f57 100644 --- a/js/foundation/foundation.slider.js +++ b/js/foundation/foundation.slider.js @@ -53,6 +53,22 @@ } }) .on('mouseup.fndtn.slider touchend.fndtn.slider pointerup.fndtn.slider', function (e) { + if(!self.cache.active) { + // if the user has just clicked into the slider without starting to drag the handle + var slider = $(e.target).attr('role') === 'slider' ? $(e.target) : $(e.target).closest('.range-slider').find("[role='slider']"); + if (slider.length) { + self.set_active_slider(slider); + if ($.data(self.cache.active[0], 'settings').vertical) { + var scroll_offset = 0; + if (!e.pageY) { + scroll_offset = window.scrollY; + } + self.calculate_position(self.cache.active, self.get_cursor_position(e, 'y') + scroll_offset); + } else { + self.calculate_position(self.cache.active, self.get_cursor_position(e, 'x')); + } + } + } self.remove_active_slider(); }) .on('change.fndtn.slider', function (e) { -- 2.47.2