xiongchiamiov / my-life-for-aiur

Javascript implementation of the children's card game War

Home Page:http://changedmy.name/my-life-for-aiur/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DRY out those damned setTimeout() calls

xiongchiamiov opened this issue · comments

There are some things that we don't want to happen until certain animations are finished. Currently, this is done by wrapping them in setTimeout calls, with the second parameter being the same as the duration of the animation.

If you want to tweak the length of an animation, you have to adjust the timeout value as well. More importantly, having the timeout come after the closure is ugly and puts the information too far away from where you're looking for it.

MooTools allows one to moneky-patch methods into classes, so the best method is probably to write a wrapper for Fx.Move that takes in a closure to be called after the animation's done.

Implement Element.move_and_call; closed by 1827298.

So, it seems that most of the setTimeout calls aren't actually being called
after animations, or at least in the way that would benefit from this change.
Oh well.