Skip to content

Commit

Permalink
Remove throttle
Browse files Browse the repository at this point in the history
- should be a concern of the caller
  • Loading branch information
johnwalley committed Nov 6, 2017
1 parent 9bac9cf commit f008531
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 31 deletions.
28 changes: 12 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d3-simple-slider",
"version": "0.1.4",
"version": "0.1.5",
"description": "Displays an SVG slider",
"keywords": ["d3", "d3-module", "slider", "visualization"],
"homepage": "https://github.com/johnwalley/d3-simple-slider",
Expand Down Expand Up @@ -34,7 +34,6 @@
"uglify-js": "^3.1.4"
},
"dependencies": {
"d3": "^4.11.0",
"lodash": "^4.17.4"
"d3": "^4.11.0"
}
}
20 changes: 8 additions & 12 deletions src/slider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as d3 from "d3";
import _ from "lodash";

function slider() {
var value = 0;
Expand Down Expand Up @@ -163,27 +162,24 @@ function slider() {
if (value !== newValue) {
value = newValue;
dispatch.call("onchange", slider, newValue);
fadeTickText();
}
}

var throttleUpdate = _.throttle(function(newValue) {
dispatch.call("drag", slider, newValue);

if (value !== newValue) {
value = newValue;
dispatch.call("onchange", slider, newValue);
}
}, 150);

function dragged() {
var pos = identityClamped(d3.event.x);
var newValue = alignedValue(scale.invert(pos));
selection
.select(".parameter-value")
.attr("transform", "translate(" + scale(newValue) + "," + -10 + ")");
fadeTickText();
selection.select(".parameter-value text").text(tickFormat(newValue));
throttleUpdate(newValue);
dispatch.call("drag", slider, newValue);
fadeTickText();

if (value !== newValue) {
value = newValue;
dispatch.call("onchange", slider, newValue);
}
}

function dragended() {
Expand Down

0 comments on commit f008531

Please sign in to comment.