Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
double-clicking using D3.js in the browser
d3DomUIElement.on("click", clickAndDoubleClick(toggleSelectionHandler, selectAndStartEditingHandler));
clickAndDoubleClick = function(singlecallback, doublecallback) {
var f;
f = void 0;
return f = (function() {
var doubleclick, firstclick, g, t1, timer;
firstclick = true;
timer = null;
t1 = null;
doubleclick = false;
g = void 0;
return g = function(d) {
var duration, self, t2;
d3.event.stopPropagation();
self = this;
if (firstclick) {
timer = d3.timeout((function(elapsed) {
var duration, t2;
if (doubleclick) {
} else {
t2 = +new Date();
duration = t2 - t1;
t1 = t2;
firstclick = true;
singlecallback.call(self, d);
}
}), 250);
firstclick = false;
t1 = +new Date();
} else {
t2 = +new Date();
duration = t2 - t1;
t1 = t2;
if (duration < 300) {
timer.stop();
firstclick = true;
doublecallback.call(self, d);
} else {
timer.stop();
window.console.log("*** Error: double click handler fallthrough: " + duration + 'ms');
}
}
};
})();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.