From: Burtchen Date: Fri, 10 Jul 2015 20:58:55 +0000 (+0200) Subject: slider: add support for changing a value by clicking on the slider without having... X-Git-Tag: v5.5.3~40^2~4^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F6695%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git slider: add support for changing a value by clicking on the slider without having started to drag from the handle --- 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) {