added requestAnimationFrame for smoother transitions on mobile