In this section you'll make it so when you click on the word-viewer, the animation plays in reverse.

New internal state is needed to represent the current animation playDirection.

Next, update the math that finds the displayed word in the render() method to account for a negative this.idx.

Change tickToNextWord to choose the next word based on the playDirection.

And add a switchPlayDirection method to invert the playDirection.

Finally, bind this.switchPlayDirection to invoke when the <pre> element is clicked using Lit's declarative event listener syntax.

Event listeners added using the declarative @ syntax in the template are automatically bound to the component, so no arrow function is required. See more in the event docs.

Click the word-viewer in the preview, the word animation should reverse in direction.

It's difficult to tell what direction the animation is playing in, so in the next section you'll add dynamic styles based on the animation direction.