Understanding how the reqeustAnimation frame works in canvas