Improve the requestAnimFrame function to be compatible with 30fps, etc