vasturiano/force-graph

Can the blinking function be applied?

Opened this issue · 4 comments

Hi,
I draw 2d-graph with default symbol and image symbol.
when I click node, I want to add a function that blinking once per second.
However, the node did not change.
Am I doing something wrong? Or is it a function that shouldn't be?

thank you!

@NoviceInWeb thanks for reaching out.

There is no built-in functionality in this module to blink nodes. You'd have to code that yourself, but it should be doable. If you use nodeCanvasObject to render you custom node, that method gets invoked once at every frame. Thus all you'd need is some interpolation function that determines the node opacity/visibility in function of time, according to your needs.

@vasturiano thank you for answer.

I try to add my blink function.
But it blinks irregularly.

What's wrong with this code??😒 thank you...

my code:
https://codepen.io/LolaKane/pen/YzePQLa

@NoviceInWeb you were close. You just had to move the setInterval creation out of the nodeVisibility method, otherwise you're creating a new interval at every frame, leading into an enormous amount of interval events.
https://codepen.io/vasturiano/pen/eYVNOyQ

oh,
It works nice and clearly. 👌
thank you very much. Bye!