summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-05-21 09:52:19 +0200
committerPeter Wu <peter@lekensteyn.nl>2014-05-21 09:52:19 +0200
commit0a5c3a28330e7b8f18b950bb98aa3ac1ae234537 (patch)
tree99d1d5b4b63e24697da5917902f6a266beffbc8d
parent57bfa4fe42c10e254a96817586d5e64de45cdf9d (diff)
downloadd3viz-0a5c3a28330e7b8f18b950bb98aa3ac1ae234537.tar.gz
Fix such dragging is limited to the bar
-rw-r--r--bubble.html1
-rw-r--r--bubble.js36
2 files changed, 20 insertions, 17 deletions
diff --git a/bubble.html b/bubble.html
index c6305d4..e50fab1 100644
--- a/bubble.html
+++ b/bubble.html
@@ -108,7 +108,6 @@ html, body {
<body>
<div id="infobox">
- <!-- TODO: make this bar the only initiator of dragging -->
<div class="draggable"></div>
<div class="content">
<ul class="status">
diff --git a/bubble.js b/bubble.js
index 9724886..ccc4f4a 100644
--- a/bubble.js
+++ b/bubble.js
@@ -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() {