Stop killing my CPU

22 views
Skip to first unread message

JohnRam

unread,
Jun 21, 2009, 7:54:44 AM6/21/09
to js-mindmap
Try this:
1. remove setInterval and replace it with setTimeout
The animation speed will vary depending on CPU speed, but it won't
overflow slower machines.

2. add "moving" indicator to all nodes (1=node is moving, 2=node is
not moving)
When there are no moving nodes, then setTimeout for 1 full second,
otherwise setTimeout for 40ms.
This will use less CPU once all nodes find their place.

3. make nodes run faster (and reach their place faster)
var minSpeed = 0.9;
var maxForce = 0.5;

4. use ctx.lineTo instead of ctx.quadraticCurveTo in
SpiderLine.prototype.updatePosition.
Looks less "groovy" but draws faster and produces clear looking graph
(better readability).

1+2+3+4 makes a big difference.

This is a very cool script you're making. Looking forward to future
versions of it.
It won't help me much with my own project - I need much less dynamic
js-mindmap. People remember when there's something on the right or
left, and this script moves everything around too much. Still - some
ideas will help me for sure.
If you find some ready-to-use js mindmap drawing lib - let me know,
okay? johnr...@gmail.com
Regards
JohnRam
Reply all
Reply to author
Forward
0 new messages