Skip to Main Content
Mastering React Test-Driven Development - Second Edition
book

Mastering React Test-Driven Development - Second Edition

by Daniel Irvine
September 2022
Intermediate to advanced content levelIntermediate to advanced
564 pages
9h 56m
English
Packt Publishing
Content preview from Mastering React Test-Driven Development - Second Edition

15

Adding Animation

Animation lends itself to test-driven development just as much as any other feature. In this chapter, we’ll animate the Logo turtle movement as the user inputs commands.

There are two types of animation in Spec Logo:

  • First, when the turtle moves forward. For example, when the user enters forward 100 as an instruction, the turtle should move 100 units along, at a fixed speed. As it moves, it will draw a line behind it.
  • Second, when the turtle rotates. For example, if the user types rotate 90, then the turtle should rotate slowly until it has made a quarter turn.

Much of this chapter is about test-driving the window.requestAnimationFrame function. This is the browser API that allows us to animate visual elements on the screen, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Full-Stack Web Development with GraphQL and React - Second Edition

Full-Stack Web Development with GraphQL and React - Second Edition

Sebastian Grebe

Publisher Resources

ISBN: 9781803247120Supplemental Content