Browse Source

- Added pointer properties to the click and the doubleClick events containing the XY coordinates in DOM and canvas space.

v3_develop
Alex de Mulder 10 years ago
parent
commit
37c80b1931
5 changed files with 25834 additions and 25805 deletions
  1. +3
    -0
      HISTORY.md
  2. +25812
    -25802
      dist/vis.js
  3. +4
    -0
      docs/network.html
  4. +3
    -1
      examples/network/02_random_nodes.html
  5. +12
    -2
      lib/network/mixins/SelectionMixin.js

+ 3
- 0
HISTORY.md View File

@ -8,6 +8,9 @@ http://visjs.org
- Added points style for scatterplots and pointclouds. - Added points style for scatterplots and pointclouds.
- Modularized the Graph2D draw styles. - Modularized the Graph2D draw styles.
### Network
- Added pointer properties to the click and the doubleClick events containing the XY coordinates in DOM and canvas space.
## 2014-11-07, version 3.6.4 ## 2014-11-07, version 3.6.4

+ 25812
- 25802
dist/vis.js
File diff suppressed because it is too large
View File


+ 4
- 0
docs/network.html View File

@ -2382,6 +2382,8 @@ network.off('select', onSelect);
<ul> <ul>
<li><code>nodes</code>: an array with the ids of the selected nodes</li> <li><code>nodes</code>: an array with the ids of the selected nodes</li>
<li><code>edges</code>: an array with the ids of the selected edges</li> <li><code>edges</code>: an array with the ids of the selected edges</li>
<li><code>pointer.DOM</code>:object containing XY coordinates in the DOM</li>
<li><code>pointer.canvas</code>:object containing XY coordinates in the canvas</li>
</ul> </ul>
</td> </td>
</tr> </tr>
@ -2392,6 +2394,8 @@ network.off('select', onSelect);
<ul> <ul>
<li><code>nodes</code>: an array with the ids of the selected nodes</li> <li><code>nodes</code>: an array with the ids of the selected nodes</li>
<li><code>edges</code>: an array with the ids of the selected edges</li> <li><code>edges</code>: an array with the ids of the selected edges</li>
<li><code>pointer.DOM</code>:object containing XY coordinates in the DOM</li>
<li><code>pointer.canvas</code>:object containing XY coordinates in the canvas</li>
</ul> </ul>
</td> </td>
</tr> </tr>

+ 3
- 1
examples/network/02_random_nodes.html View File

@ -77,7 +77,9 @@
}; };
var options = {stabilization:false}; var options = {stabilization:false};
network = new vis.Network(container, data, options); network = new vis.Network(container, data, options);
network.on('click', function(params) {
console.log(params)
});
// add event listeners // add event listeners
network.on('select', function(params) { network.on('select', function(params) {
document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes; document.getElementById('selection').innerHTML = 'Selection: ' + params.nodes;

+ 12
- 2
lib/network/mixins/SelectionMixin.js View File

@ -506,7 +506,12 @@ exports._handleTap = function(pointer) {
this._unselectAll(); this._unselectAll();
} }
} }
this.emit("click", this.getSelection());
var properties = this.getSelection();
properties['pointer'] = {
DOM: {x: pointer.x, y: pointer.y},
canvas: {x: this._XconvertDOMtoCanvas(pointer.x), y: this._YconvertDOMtoCanvas(pointer.y)}
}
this.emit("click", properties);
this._redraw(); this._redraw();
}; };
@ -525,7 +530,12 @@ exports._handleDoubleTap = function(pointer) {
"y" : this._YconvertDOMtoCanvas(pointer.y)}; "y" : this._YconvertDOMtoCanvas(pointer.y)};
this.openCluster(node); this.openCluster(node);
} }
this.emit("doubleClick", this.getSelection());
var properties = this.getSelection();
properties['pointer'] = {
DOM: {x: pointer.x, y: pointer.y},
canvas: {x: this._XconvertDOMtoCanvas(pointer.x), y: this._YconvertDOMtoCanvas(pointer.y)}
}
this.emit("doubleClick", properties);
}; };

Loading…
Cancel
Save