diff options
author | Peter Wu <peter@lekensteyn.nl> | 2014-05-21 09:52:19 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2014-05-21 09:52:19 +0200 |
commit | 0a5c3a28330e7b8f18b950bb98aa3ac1ae234537 (patch) | |
tree | 99d1d5b4b63e24697da5917902f6a266beffbc8d /bubble.js | |
parent | 57bfa4fe42c10e254a96817586d5e64de45cdf9d (diff) | |
download | d3viz-0a5c3a28330e7b8f18b950bb98aa3ac1ae234537.tar.gz |
Fix such dragging is limited to the bar
Diffstat (limited to 'bubble.js')
-rw-r--r-- | bubble.js | 36 |
1 files changed, 20 insertions, 16 deletions
@@ -285,22 +285,26 @@ function processData(data) { // initialize information panel (function () { var infoPane = d3.select('#infobox'); - // SHIT: d3js cannot handle drag with nested elements --> stutter! - // BREAKS TEXT SELECTION :( - infoPane //.select('.draggable') - .call(d3.behavior.drag() - .on('drag', function () { - var changes = { - 'left': d3.event.dx, - 'top': d3.event.dy - }; - // add the differences to the old positions - for (var name in changes) { - var newValue = parseInt(infoPane.style(name)); - newValue += changes[name]; - infoPane.style(name, newValue + 'px'); - } - })); + infoPane.select('.draggable') + .on('mousedown', function () { + infoPane.call(d3.behavior.drag().on('drag', dragger)); + }) + .on('mouseup', function () { + infoPane.on('mousedown.drag', null); + }); + + function dragger() { + var changes = { + 'left': d3.event.dx, + 'top': d3.event.dy + }; + // add the differences to the old positions + for (var name in changes) { + var newValue = parseInt(infoPane.style(name)); + newValue += changes[name]; + infoPane.style(name, newValue + 'px'); + } + } }()); function run() { |