All examples By author By category About

erkal

playButton

playButton

Here is a simple mechanism mainly for the purpose of building step by step illustrations in bl.ocks.org.

It is better compared to using setTimeouts, because

The function playButton takes as arguments an svg element svg, a function list fnList and coordinates x & y. It appends a play button into svg, which on mousedown event, evaluates the functions in fnList one by one.

playButton uses a scoped variable i to store its state.

On mouseover, you can see the function that play button is going to evaluate next.

playButton removes it self, when the end of fnList is reached.

An example usage is here: General Update Pattern with playButton