diff --git a/dist/vis.js b/dist/vis.js index 54bc019a..dc2a3dda 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -4,9 +4,7 @@ * * A dynamic, browser-based visualization library. * - - * @version 0.6.0-SNAPSHOT - + * @version 0.7.0-SNAPSHOT * @date 2014-03-05 * * @license @@ -11676,6 +11674,7 @@ var physicsMixin = { */ _loadPhysicsConfiguration : function() { if (this.physicsConfiguration === undefined) { + var hierarchicalLayoutDirections = ["LR","RL","UD","DU"]; this.physicsConfiguration = document.createElement('div'); this.physicsConfiguration.className = "PhysicsConfiguration"; this.physicsConfiguration.innerHTML = '' + @@ -11689,127 +11688,109 @@ var physicsMixin = { ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ ''+ - ''+ + ''+ ''+ '' this.containerElement.parentElement.insertBefore(this.physicsConfiguration,this.containerElement); - var hierarchicalLayoutDirections = ["LR","RL","UD","DU"]; + var rangeElement; rangeElement = document.getElementById('graph_BH_gc'); - rangeElement.innerHTML = this.constants.physics.barnesHut.gravitationalConstant; rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_gc',-1,"physics_barnesHut_gravitationalConstant"); rangeElement = document.getElementById('graph_BH_cg'); - rangeElement.innerHTML = this.constants.physics.barnesHut.centralGravity; rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_cg',1,"physics_centralGravity"); rangeElement = document.getElementById('graph_BH_sc'); - rangeElement.innerHTML = this.constants.physics.barnesHut.springConstant; rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_sc',1,"physics_springConstant"); rangeElement = document.getElementById('graph_BH_sl'); - rangeElement.innerHTML = this.constants.physics.barnesHut.springLength; rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_sl',1,"physics_springLength"); rangeElement = document.getElementById('graph_BH_damp'); - rangeElement.innerHTML = this.constants.physics.barnesHut.damping; rangeElement.onchange = showValueOfRange.bind(this,'graph_BH_damp',1,"physics_damping"); rangeElement = document.getElementById('graph_R_nd'); - rangeElement.innerHTML = this.constants.physics.repulsion.nodeDistance; rangeElement.onchange = showValueOfRange.bind(this,'graph_R_nd',1,"physics_repulsion_nodeDistance"); rangeElement = document.getElementById('graph_R_cg'); - rangeElement.innerHTML = this.constants.physics.repulsion.centralGravity; rangeElement.onchange = showValueOfRange.bind(this,'graph_R_cg',1,"physics_centralGravity"); rangeElement = document.getElementById('graph_R_sc'); - rangeElement.innerHTML = this.constants.physics.repulsion.springConstant; rangeElement.onchange = showValueOfRange.bind(this,'graph_R_sc',1,"physics_springConstant"); rangeElement = document.getElementById('graph_R_sl'); - rangeElement.innerHTML = this.constants.physics.repulsion.springLength; rangeElement.onchange = showValueOfRange.bind(this,'graph_R_sl',1,"physics_springLength"); rangeElement = document.getElementById('graph_R_damp'); - rangeElement.innerHTML = this.constants.physics.repulsion.damping; rangeElement.onchange = showValueOfRange.bind(this,'graph_R_damp',1,"physics_damping"); rangeElement = document.getElementById('graph_H_nd'); - rangeElement.innerHTML = this.constants.physics.hierarchicalRepulsion.nodeDistance; rangeElement.onchange = showValueOfRange.bind(this,'graph_H_nd',1,"physics_hierarchicalRepulsion_nodeDistance"); rangeElement = document.getElementById('graph_H_cg'); - rangeElement.innerHTML = this.constants.physics.hierarchicalRepulsion.centralGravity; rangeElement.onchange = showValueOfRange.bind(this,'graph_H_cg',1,"physics_centralGravity"); rangeElement = document.getElementById('graph_H_sc'); - rangeElement.innerHTML = this.constants.physics.hierarchicalRepulsion.springConstant; rangeElement.onchange = showValueOfRange.bind(this,'graph_H_sc',1,"physics_springConstant"); rangeElement = document.getElementById('graph_H_sl'); - rangeElement.innerHTML = this.constants.physics.hierarchicalRepulsion.springLength; rangeElement.onchange = showValueOfRange.bind(this,'graph_H_sl',1,"physics_springLength"); rangeElement = document.getElementById('graph_H_damp'); - rangeElement.innerHTML = this.constants.physics.hierarchicalRepulsion.damping; rangeElement.onchange = showValueOfRange.bind(this,'graph_H_damp',1,"physics_damping"); rangeElement = document.getElementById('graph_H_direction'); - rangeElement.innerHTML = hierarchicalLayoutDirections.indexOf(this.constants.hierarchicalLayout.direction); rangeElement.onchange = showValueOfRange.bind(this,'graph_H_direction',hierarchicalLayoutDirections,"hierarchicalLayout_direction"); rangeElement = document.getElementById('graph_H_levsep'); - rangeElement.innerHTML = this.constants.hierarchicalLayout.levelSeparation; rangeElement.onchange = showValueOfRange.bind(this,'graph_H_levsep',1,"hierarchicalLayout_levelSeparation"); rangeElement = document.getElementById('graph_H_nspac'); - rangeElement.innerHTML = this.constants.hierarchicalLayout.nodeSpacing; rangeElement.onchange = showValueOfRange.bind(this,'graph_H_nspac',1,"hierarchicalLayout_nodeSpacing"); var radioButton1 = document.getElementById("graph_physicsMethod1"); @@ -16753,7 +16734,6 @@ Graph.prototype._zoom = function(scale, pointer) { this.areaCenter = {"x" : this._canvasToX(pointer.x), "y" : this._canvasToY(pointer.y)}; - this.pinch.mousewheelScale = scale; this._setScale(scale); this._setTranslation(tx, ty); this.updateClustersDefault(); @@ -16785,12 +16765,9 @@ Graph.prototype._onMouseWheel = function(event) { // Basically, delta is now positive if wheel was scrolled up, // and negative, if wheel was scrolled down. if (delta) { - if (!('mousewheelScale' in this.pinch)) { - this.pinch.mousewheelScale = 1; - } // calculate the new scale - var scale = this.pinch.mousewheelScale; + var scale = this._getScale(); var zoom = delta / 10; if (delta < 0) { zoom = zoom / (1 - zoom); @@ -16803,9 +16780,6 @@ Graph.prototype._onMouseWheel = function(event) { // apply the new scale this._zoom(scale, pointer); - - // store the new, applied scale -- this is now done in _zoom -// this.pinch.mousewheelScale = scale; } // Prevent default actions caused by mouse wheel. @@ -17353,7 +17327,6 @@ Graph.prototype._getTranslation = function() { */ Graph.prototype._setScale = function(scale) { this.scale = scale; - this.pinch.mousewheelScale = scale; }; /** @@ -17580,6 +17553,9 @@ Graph.prototype._animationStep = function() { }; +window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || + window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; + /** * Schedule a animation step with the refreshrate interval. * @@ -17587,8 +17563,8 @@ Graph.prototype._animationStep = function() { */ Graph.prototype.start = function() { if (this.moving || this.xIncrement != 0 || this.yIncrement != 0 || this.zoomIncrement != 0) { - if (!this.timer) { - this.timer = window.setTimeout(this._animationStep.bind(this), this.renderTimestep); // wait this.renderTimeStep milliseconds and perform the animation step function + if (!this.timer) { + this.timer = window.requestAnimationFrame(this._animationStep.bind(this), this.renderTimestep); // wait this.renderTimeStep milliseconds and perform the animation step function } } else { diff --git a/src/graph/Graph.js b/src/graph/Graph.js index 4366917f..7e91342b 100644 --- a/src/graph/Graph.js +++ b/src/graph/Graph.js @@ -1806,6 +1806,9 @@ Graph.prototype._animationStep = function() { }; +window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || + window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; + /** * Schedule a animation step with the refreshrate interval. * @@ -1813,8 +1816,8 @@ Graph.prototype._animationStep = function() { */ Graph.prototype.start = function() { if (this.moving || this.xIncrement != 0 || this.yIncrement != 0 || this.zoomIncrement != 0) { - if (!this.timer) { - this.timer = window.setTimeout(this._animationStep.bind(this), this.renderTimestep); // wait this.renderTimeStep milliseconds and perform the animation step function + if (!this.timer) { + this.timer = window.requestAnimationFrame(this._animationStep.bind(this), this.renderTimestep); // wait this.renderTimeStep milliseconds and perform the animation step function } } else {