Add sync function.

The sync function makes it easy to synchronize multiple animation
queues: by running sync(a, b, c), all the specified elements will
wait for each other to get to this point before proceeding.