I'm using Vis.js to draw network diagrams. I'd like to be able to have a notification feature that when an AJAX update is received for a specific node the canvas moves that node to the center (which Vis.js can already do) and then have some type of bullseye animation over the node to draw the users attention until they click the node. The closest example to the animation effect I'm looking for is at http://codepen.io/MateiGCopot/pen/ogEKRK
var w = c.width = 400,
h = c.height = 400,
ctx = c.getContext('2d'),
frame = 0;
function anim(){
window.requestAnimationFrame(anim);
++frame;
for(var i = 0; i < w; ++i){
ctx.strokeStyle = i%20 === 0 ? 'hsl(hue, 80%, 50%)'.replace('hue',
(360 / (w/3) * i - frame) % 360
) : 'rgba(0, 0, 0, .08)';
ctx.beginPath();
ctx.arc(w/2, h/2, (i + frame)%w/2, 0, Math.PI*2);
ctx.stroke();
ctx.closePath();
}
}
anim();
Is this the best way to achieve this type of effect? Running it on my machine makes the CPU usage spike so it doesn't seem to be that efficient.
Also, how can I integrate something like this with Vis.js so it draws over an image node and will stop when the node is clicked? This particular example draws the circles outward however, I'd like them to be drawn inwards but couldn't figure out how to change the direction.
JavaScript is not my strong suite so the more detailed the explanation the better. Also, I'm not specifically tied to Vis.js so if there is another library that already has this functionality (along with comparable Vis.js features) I'd be alright with switching.