]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
slider: add support for changing a value by clicking on the slider without having... 6695/head
authorBurtchen <Burtchen@web.de>
Fri, 10 Jul 2015 20:58:55 +0000 (22:58 +0200)
committerBurtchen <Burtchen@web.de>
Fri, 10 Jul 2015 20:58:55 +0000 (22:58 +0200)
js/foundation/foundation.slider.js

index 23098250e8642fd0d3e7c0b4f66ccb2f4336082b..87f7a3f573022d70aa61042dcf5be72ad7a9731f 100644 (file)
           }
         })
         .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) {