@andespindola/brainlink 0.1.0-beta.23 → 0.1.0-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -201,7 +201,9 @@ const createLayout = graph => {
|
|
|
201
201
|
const nodes = graph.nodes.map(node => ({
|
|
202
202
|
...node,
|
|
203
203
|
x: Number.isFinite(node.x) ? node.x : 0,
|
|
204
|
-
y: Number.isFinite(node.y) ? node.y : 0
|
|
204
|
+
y: Number.isFinite(node.y) ? node.y : 0,
|
|
205
|
+
vx: Number.isFinite(node.vx) ? node.vx : 0,
|
|
206
|
+
vy: Number.isFinite(node.vy) ? node.vy : 0
|
|
205
207
|
}))
|
|
206
208
|
const nodeMap = new Map(nodes.map(node => [node.id, node]))
|
|
207
209
|
const edges = graph.edges
|
|
@@ -296,6 +298,10 @@ const tick = delta => {
|
|
|
296
298
|
edges.forEach(edge => {
|
|
297
299
|
const source = edge.sourceNode
|
|
298
300
|
const target = edge.targetNode
|
|
301
|
+
source.vx = Number.isFinite(source.vx) ? source.vx : 0
|
|
302
|
+
source.vy = Number.isFinite(source.vy) ? source.vy : 0
|
|
303
|
+
target.vx = Number.isFinite(target.vx) ? target.vx : 0
|
|
304
|
+
target.vy = Number.isFinite(target.vy) ? target.vy : 0
|
|
299
305
|
const dx = target.x - source.x
|
|
300
306
|
const dy = target.y - source.y
|
|
301
307
|
const distance = Math.max(Math.hypot(dx, dy), 1)
|
|
@@ -312,6 +318,10 @@ const tick = delta => {
|
|
|
312
318
|
for (let j = i + 1; j < nodes.length; j += 1) {
|
|
313
319
|
const a = nodes[i]
|
|
314
320
|
const b = nodes[j]
|
|
321
|
+
a.vx = Number.isFinite(a.vx) ? a.vx : 0
|
|
322
|
+
a.vy = Number.isFinite(a.vy) ? a.vy : 0
|
|
323
|
+
b.vx = Number.isFinite(b.vx) ? b.vx : 0
|
|
324
|
+
b.vy = Number.isFinite(b.vy) ? b.vy : 0
|
|
315
325
|
const dx = b.x - a.x
|
|
316
326
|
const dy = b.y - a.y
|
|
317
327
|
const distance = Math.max(Math.hypot(dx, dy), 1)
|
|
@@ -326,6 +336,10 @@ const tick = delta => {
|
|
|
326
336
|
}
|
|
327
337
|
|
|
328
338
|
nodes.forEach(node => {
|
|
339
|
+
node.vx = Number.isFinite(node.vx) ? node.vx : 0
|
|
340
|
+
node.vy = Number.isFinite(node.vy) ? node.vy : 0
|
|
341
|
+
node.x = Number.isFinite(node.x) ? node.x : 0
|
|
342
|
+
node.y = Number.isFinite(node.y) ? node.y : 0
|
|
329
343
|
if (state.pointer.dragNode === node) {
|
|
330
344
|
node.vx = 0
|
|
331
345
|
node.vy = 0
|
package/package.json
CHANGED