Browse Source

fixed selectable for network #371

v3_develop
Alex de Mulder 10 years ago
parent
commit
6ca1700087
6 changed files with 2064 additions and 2039 deletions
  1. +1
    -1
      HISTORY.md
  2. +2023
    -2016
      dist/vis.js
  3. +3
    -3
      docs/network.html
  4. +24
    -7
      lib/network/Network.js
  5. +13
    -11
      lib/network/mixins/SelectionMixin.js
  6. +0
    -1
      lib/timeline/Range.js

+ 1
- 1
HISTORY.md View File

@ -9,7 +9,7 @@ http://visjs.org
- Renamed storePosition to storePositions. Added deprication message and old name still works.
- Worked around hammer.js bug with multiple release listeners.
- Improved cleaning up after manipulation toolbar.
- Added getPositions() method to get the position of all nodes.
- Added getPositions() method to get the position of all nodes or some of them if specific Ids are supplied.
- Added getCenterCoordinates() method to get the x and y position in canvas space of the center of the view.
- Fixed node label becoming undefined.
- Fixed cluster fontsize scaling.

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


+ 3
- 3
docs/network.html View File

@ -2287,9 +2287,9 @@ var options: {
or in percentages.</td>
</tr>
<tr>
<td>getPositions()</td>
<td>none</td>
<td>This will return an object of all nodes' positions. Data can be accessed with object[nodeId].x and .y.
<td>getPositions([ids])</td>
<td>Object</td>
<td>This will return an object of all nodes' positions. Data can be accessed with object[nodeId].x and .y. You can optionally supply an id as string or number or an array of ids. If no id or array of ids have been supplied, all positions are returned.
</td>
</tr>
<tr>

+ 24
- 7
lib/network/Network.js View File

@ -2284,14 +2284,32 @@ Network.prototype.storePositions = function() {
};
/**
* Load the XY positions of the nodes into the dataset.
* Return the positions of the nodes.
*/
Network.prototype.getPositions = function() {
Network.prototype.getPositions = function(ids) {
var dataArray = {};
for (var nodeId in this.nodes) {
if (this.nodes.hasOwnProperty(nodeId)) {
var node = this.nodes[nodeId];
dataArray[nodeId] = {x:Math.round(node.x),y:Math.round(node.y)};
if (ids !== undefined) {
if (Array.isArray(ids) == true) {
for (var i = 0; i < ids.length; i++) {
if (this.nodes[ids[i]] !== undefined) {
var node = this.nodes[ids[i]];
dataArray[ids[i]] = {x: Math.round(node.x), y: Math.round(node.y)};
}
}
}
else {
if (this.nodes[ids] !== undefined) {
var node = this.nodes[ids];
dataArray[ids] = {x: Math.round(node.x), y: Math.round(node.y)};
}
}
}
else {
for (var nodeId in this.nodes) {
if (this.nodes.hasOwnProperty(nodeId)) {
var node = this.nodes[nodeId];
dataArray[nodeId] = {x: Math.round(node.x), y: Math.round(node.y)};
}
}
}
return dataArray;
@ -2514,5 +2532,4 @@ Network.prototype.getCenterCoordinates = function () {
return this.DOMtoCanvas({x: 0.5 * this.frame.canvas.clientWidth, y: 0.5 * this.frame.canvas.clientHeight});
};
module.exports = Network;

+ 13
- 11
lib/network/mixins/SelectionMixin.js View File

@ -487,21 +487,23 @@ exports._handleTouch = function(pointer) {
* @private
*/
exports._handleTap = function(pointer) {
var node = this._getNodeAt(pointer);
if (node != null) {
this._selectObject(node,false);
}
else {
var edge = this._getEdgeAt(pointer);
if (edge != null) {
this._selectObject(edge,false);
if (this.constants.selectable == true) {
var node = this._getNodeAt(pointer);
if (node != null) {
this._selectObject(node, false);
}
else {
this._unselectAll();
var edge = this._getEdgeAt(pointer);
if (edge != null) {
this._selectObject(edge, false);
}
else {
this._unselectAll();
}
}
this.emit("click", this.getSelection());
this._redraw();
}
this.emit("click", this.getSelection());
this._redraw();
};

+ 0
- 1
lib/timeline/Range.js View File

@ -616,7 +616,6 @@ Range.prototype.zoom = function(scale, center, delta) {
// calculate new start and end
var newStart = center + (this.start - center) * scale;
var newEnd = (center+hiddenDuration) + (this.end - (center+hiddenDuration)) * scale;
// snapping times away from hidden zones
this.startToFront = delta > 0 ? false : true; // used to do the right autocorrection with periodic hidden times
this.endToFront = -delta > 0 ? false : true; // used to do the right autocorrection with periodic hidden times

Loading…
Cancel
Save