Add option to use timeout instead of animation frame