JavaScript: Smart routing in JointJS (performance issue?) -


i have been looking @ jointjs routing demo ( http://www.jointjs.com/demos/routing ), managed apply in web application. example has single link between 2 elements , has 3 obstacles, whilst in application, have 50 elements (which can sources, targets , obstacles @ same time) on 80 links between them.

i have list of elements on page: listofelements, , list of of links between them: listoflinks

following logic jointjs.com link above, i'm doing following:

graph.on('change:position', function(cell) {     // have elements been moved? reroute of links.     for(var j = 0; j < listoflinks.length; ++j) {        if (_.contains(listofelements, cell)) paper.findviewbymodel(listoflinks).update();     } });  

the above kind of trick, huge hit on performance when drag elements around, since every single link checked whenever move element.

  1. is there efficient way check collision of link , element in jointjs? i've been digging around, can't seem find information on matter.

  2. am doing suicidal performance-wise here? there way speed things up?

i open other suggestions on smart routing besides jointjs. have tried jsplumb, no success. appreciated.

thanks in advance, guys, , keep work!

i have looked @ example briefly, strange iterate listoflinks.length times, , send in links each of times.

how about:

graph.on('change:position', function(cell) {     if (_.contains(listofelements, cell)) {         (var i=0; i<listoflinks.length; i++) {             paper.findviewbymodel(listoflinks[i]).update();         }     } }); 

i tried how update links in area, unfortunately seems easy find overlapping elements. came with:

function overlap(rect1, rect2) {     return !(rect1.right < rect2.left ||               rect1.left > rect2.right ||               rect1.bottom < rect2.top ||               rect1.top > rect2.bottom); }  graph.on('change:position', function(cell) {     if (_.contains(listofelements, cell)) {         var bbox = paper.findviewbymodel(cell);         _.each(listoflinks, function(link) {             var linkview = paper.findviewbymodel(link);             if (overlap(linkview.getbbox(), bbox)) {                 linkview.update();             }         });     } }); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -