summaryrefslogtreecommitdiff
path: root/bubble.js
diff options
context:
space:
mode:
Diffstat (limited to 'bubble.js')
-rw-r--r--bubble.js36
1 files changed, 20 insertions, 16 deletions
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() {