change canvas timer to on animateframe