Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript jQuery Basics (2014) Creating a Simple Drawing Application More Mouse Events

Perfecting the drawing app

Instead of firing the mouseup event you can just set the mouse down to false.. so mouseleave(function(){ mouseDown = false; });

1 Answer

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

You could do that, but imagine if the code got more complicated when you finish drawing. It may be simple to change mouseDown = x in two places right now but it could get hairy.

Maybe you could have a function called finishDrawing()...

function finishDrawing(){
  mouseDown = false;



Then you only have to edit the code in one place. I just wanted to illustrate triggering an event in the video :)