Event handling

We now have an idea for building the Meme Creator. Our first step is to create a function that renders the meme to the canvas. Inside the Memes class, create a function createMeme() that is going to contain our primary canvas renderer. For now, leave the function with a simple console statement:

createMeme() {  console.log('rendered');}

Remember, we need to render the entire canvas every time a change happens. So, we need to attach event listeners to all the input elements. You can also use HTML event attributes such as onchange we used in the previous ToDo List app. But event listeners let us handle more than one event for an element. Hence, they are widely preferred. Also, since we are using Webpack to bundle the code, we ...

Get JavaScript by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.