Browse Source

- Sidestepped double touch event from hammer (ugly.. but functional) causing strange behaviour in manipulation mode

- Better cleanup after reconnecting edges in manipulation mode
v3_develop
Alex de Mulder 10 years ago
parent
commit
d4cc65df64
5 changed files with 4280 additions and 4233 deletions
  1. +3
    -0
      HISTORY.md
  2. +4245
    -4223
      dist/vis.js
  3. +21
    -3
      lib/network/Edge.js
  4. +10
    -5
      lib/network/Network.js
  5. +1
    -2
      lib/network/mixins/ManipulationMixin.js

+ 3
- 0
HISTORY.md View File

@ -5,7 +5,10 @@ http://visjs.org
## not yet released, version 3.7.2-SNAPSHOT ## not yet released, version 3.7.2-SNAPSHOT
### Network
- Sidestepped double touch event from hammer (ugly.. but functional) causing strange behaviour in manipulation mode
- Better cleanup after reconnecting edges in manipulation mode
## 2014-11-28, version 3.7.1 ## 2014-11-28, version 3.7.1

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


+ 21
- 3
lib/network/Edge.js View File

@ -45,6 +45,9 @@ function Edge (properties, network, networkConstants) {
this.to = null; // a node this.to = null; // a node
this.via = null; // a temp node this.via = null; // a temp node
this.fromBackup = null; // used to clean up after reconnect
this.toBackup = null;; // used to clean up after reconnect
// we use this to be able to reconnect the edge to a cluster if its node is put into a cluster // we use this to be able to reconnect the edge to a cluster if its node is put into a cluster
// by storing the original information we can revert to the original connection when the cluser is opened. // by storing the original information we can revert to the original connection when the cluser is opened.
this.originalFromId = []; this.originalFromId = [];
@ -1037,7 +1040,8 @@ Edge.prototype.positionBezierNode = function() {
}; };
/** /**
* This function draws the control nodes for the manipulator. In order to enable this, only set the this.controlNodesEnabled to true.
* This function draws the control nodes for the manipulator.
* In order to enable this, only set the this.controlNodesEnabled to true.
* @param ctx * @param ctx
*/ */
Edge.prototype._drawControlNodes = function(ctx) { Edge.prototype._drawControlNodes = function(ctx) {
@ -1083,17 +1087,31 @@ Edge.prototype._drawControlNodes = function(ctx) {
* @private * @private
*/ */
Edge.prototype._enableControlNodes = function() { Edge.prototype._enableControlNodes = function() {
this.fromBackup = this.from;
this.toBackup = this.to;
this.controlNodesEnabled = true; this.controlNodesEnabled = true;
}; };
/** /**
* disable control nodes
* disable control nodes and remove from dynamicEdges from old node
* @private * @private
*/ */
Edge.prototype._disableControlNodes = function() { Edge.prototype._disableControlNodes = function() {
this.fromId = this.from.id;
this.toId = this.to.id;
if (this.fromId != this.fromBackup.id) { // from was changed, remove edge from old 'from' node dynamic edges
this.fromBackup.detachEdge(this);
}
else if (this.toId != this.toBackup.id) { // to was changed, remove edge from old 'to' node dynamic edges
this.toBackup.detachEdge(this);
}
this.fromBackup = null;
this.toBackup = null;
this.controlNodesEnabled = false; this.controlNodesEnabled = false;
}; };
/** /**
* This checks if one of the control nodes is selected and if so, returns the control node object. Else it returns null. * This checks if one of the control nodes is selected and if so, returns the control node object. Else it returns null.
* @param x * @param x
@ -1132,7 +1150,7 @@ Edge.prototype._restoreControlNodes = function() {
this.connectedNode = null; this.connectedNode = null;
this.controlNodes.from.unselect(); this.controlNodes.from.unselect();
} }
if (this.controlNodes.to.selected == true) {
else if (this.controlNodes.to.selected == true) {
this.to = this.connectedNode; this.to = this.connectedNode;
this.connectedNode = null; this.connectedNode = null;
this.controlNodes.to.unselect(); this.controlNodes.to.unselect();

+ 10
- 5
lib/network/Network.js View File

@ -231,6 +231,7 @@ function Network (container, data, options) {
this.targetTranslation = 0; this.targetTranslation = 0;
this.lockedOnNodeId = null; this.lockedOnNodeId = null;
this.lockedOnNodeOffset = null; this.lockedOnNodeOffset = null;
this.touchTime = 0;
// Node variables // Node variables
var network = this; var network = this;
@ -780,7 +781,6 @@ Network.prototype._create = function () {
this.hammerFrame = Hammer(this.frame, { this.hammerFrame = Hammer(this.frame, {
prevent_default: true prevent_default: true
}); });
this.hammerFrame.on('release', me._onRelease.bind(me) ); this.hammerFrame.on('release', me._onRelease.bind(me) );
// add the frame to the container element // add the frame to the container element
@ -854,11 +854,16 @@ Network.prototype._getPointer = function (touch) {
* @private * @private
*/ */
Network.prototype._onTouch = function (event) { Network.prototype._onTouch = function (event) {
this.drag.pointer = this._getPointer(event.gesture.center);
this.drag.pinched = false;
this.pinch.scale = this._getScale();
if (new Date().valueOf() - this.touchTime > 100) {
this.drag.pointer = this._getPointer(event.gesture.center);
this.drag.pinched = false;
this.pinch.scale = this._getScale();
// to avoid double fireing of this event because we have two hammer instances. (on canvas and on frame)
this.touchTime = new Date().valueOf();
this._handleTouch(this.drag.pointer);
this._handleTouch(this.drag.pointer);
}
}; };
/** /**

+ 1
- 2
lib/network/mixins/ManipulationMixin.js View File

@ -71,7 +71,6 @@ exports._createManipulatorBar = function() {
} }
var locale = this.constants.locales[this.constants.locale]; var locale = this.constants.locales[this.constants.locale];
if (this.edgeBeingEdited !== undefined) { if (this.edgeBeingEdited !== undefined) {
this.edgeBeingEdited._disableControlNodes(); this.edgeBeingEdited._disableControlNodes();
this.edgeBeingEdited = undefined; this.edgeBeingEdited = undefined;
@ -402,7 +401,7 @@ exports._controlNodeDrag = function(event) {
exports._releaseControlNode = function(pointer) { exports._releaseControlNode = function(pointer) {
var newNode = this._getNodeAt(pointer); var newNode = this._getNodeAt(pointer);
if (newNode != null) {
if (newNode !== null) {
if (this.edgeBeingEdited.controlNodes.from.selected == true) { if (this.edgeBeingEdited.controlNodes.from.selected == true) {
this._editEdge(newNode.id, this.edgeBeingEdited.to.id); this._editEdge(newNode.id, this.edgeBeingEdited.to.id);
this.edgeBeingEdited.controlNodes.from.unselect(); this.edgeBeingEdited.controlNodes.from.unselect();

Loading…
Cancel
Save