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.
// word-viewer.ts
render() {
...
returnhtml`<pre
@click=${this.switchPlayDirection}
>${word}</pre>`;
}
// word-viewer.js
render() {
...
returnhtml`<pre
@click=${this.switchPlayDirection}
>${word}</pre>`;
}
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.