[BUGFIX] Use less force after init

This commit is contained in:
Xaver Maierhofer 2017-10-30 03:14:08 +01:00 committed by Xaver Maierhofer
parent af589ee227
commit 57ee21f8ec
No known key found for this signature in database
GPG Key ID: 7FDCE23FD2EC9FE8

View File

@ -15,6 +15,7 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease',
var dictNodes = {};
var intLinks = [];
var movetoTimer;
var initial = 1.8;
var NODE_RADIUS_DRAG = 10;
var NODE_RADIUS_SELECT = 15;
@ -24,7 +25,7 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease',
var ZOOM_MIN = 1 / 8;
var ZOOM_MAX = 3;
var FORCE_ALPHA = 0.3;
var FORCE_ALPHA = 0.01;
draw.setTransform(transform);
@ -148,7 +149,7 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease',
.force('y', d3Force.forceY().strength(0.02))
.force('collide', d3Force.forceCollide())
.on('tick', redraw)
.alphaDecay(0.015);
.alphaDecay(0.025);
var drag = d3Drag.drag()
.subject(function () {
@ -207,7 +208,9 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease',
e.o = d;
return e;
}).filter(function (e) { return e.o.is_online;});
}).filter(function (e) {
return e.o.is_online;
});
intLinks = data.links.filter(function (d) {
return dictNodes[d.source.node_id].o.is_online && dictNodes[d.target.node_id].o.is_online;
@ -224,7 +227,11 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease',
force.nodes(intNodes);
forceLink.links(intLinks);
force.alpha(1).restart();
force.alpha(initial).velocityDecay(0.15).restart();
if (initial === 1.8) {
initial = 0.5;
}
resizeCanvas();
};