diff --git a/src/examples.html b/src/examples.html index 02f5037..b1b8c3c 100644 --- a/src/examples.html +++ b/src/examples.html @@ -73,6 +73,12 @@

Vertical slider

d3.slider().value(50).orientation("vertical")
+

Slider range with slide event: 0

+ d3.slider().domain([10,90]).on("drag", function(evt, value) {
+   d3.select('#slider8text').text(value);
+ })
+
+ @@ -95,6 +101,12 @@

Vertical slider

d3.select('#slider7').call(d3.slider().orientation("vertical")); + d3.select('#slider8').call( + d3.slider().value([10,90]) + .on("drag", function(evt, value) { + d3.select('#slider8text').text(value); + })); + diff --git a/src/slider.js b/src/slider.js index d83c2a5..de49d73 100644 --- a/src/slider.js +++ b/src/slider.js @@ -117,8 +117,10 @@ d3.slider = function module() { if (value.length === 2) { // Two handles if (Math.abs(value[0] - newValue) > Math.abs(value[1] - newValue)) { moveHandle([value[0], newValue]); + dispatch.drag(d3.event.sourceEvent, [value[0], newValue]); } else { moveHandle([newValue, value[1]]); + dispatch.drag(d3.event.sourceEvent, [newValue, value[1]]); } } else { // Single handle moveHandle(newValue); @@ -135,8 +137,10 @@ d3.slider = function module() { //console.log(lowerHandle, newValue, value); if (lowerHandle && newValue <= value[1]) { moveHandle([newValue, value[1]]); + dispatch.drag(d3.event.sourceEvent, [newValue, value[1]]); } else if (!lowerHandle && newValue >= value[0]) { moveHandle([value[0], newValue]); + dispatch.drag(d3.event.sourceEvent, [value[0], newValue]); } } else if (newValue !== value) { moveHandle(newValue); @@ -274,4 +278,4 @@ Other sliders: http://api.jqueryui.com/slider/ http://refreshless.com/nouislider/ -*/ \ No newline at end of file +*/