Khan / Khan/live-editor

mouse button gets stuck when dragging the cursor outside the canvas

Open
#196 3 comments 0 reactions 0 assignees View on GitHub
idea
Dominant language
JavaScript
Stars
776
Forks
180
PR merge metrics
No merged PRs in 30d

Description

I'm writing a simple paint program and one of the things I noticed is that the mouse button gets stuck if you drag outside the canvas. I thought maybe if I checked if `mouseIsPressed` was true that would solve the problem but it didn't. Here's the code:

```
strokeWeight(5);

mousePressed = function () {
stroke(random(0,255), random(0,255), random(0,255));
};

mouseDragged = function () {
if (mouseIsPressed) {
line(pmouseX, pmouseY, mouseX, mouseY);
}
};
```

Clicking "Restart" doesn't unstick the point. You have to click the canvas to get it back to a good state.

Another related issue is that you can't draw lines that go off the edge of the page which makes it really hard to draw a zig-zag border or the like.

Screenshot:
![screen shot 2014-11-09 at 10 30 27 pm](https://cloud.githubusercontent.com/assets/1044413/4971526/3cfc8b50-6860-11e4-9354-19b77c065ea0.png)

Link to program: https://www.khanacademy.org/computer-programming/simple-paint/4561261162659840

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the stuck-button behavior with the linked simple-paint program and the example code, then trace the live editor's canvas mouse-event handling. Check both dragging outside the canvas and drawing across its edge; done means restarting or leaving the canvas does not leave the button stuck and edge-crossing strokes behave correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.