Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track mouse activity beyond the canvas #5

Open
haydn opened this issue Jan 6, 2020 · 3 comments · May be fixed by #106
Open

Track mouse activity beyond the canvas #5

haydn opened this issue Jan 6, 2020 · 3 comments · May be fixed by #106
Assignees
Milestone

Comments

@haydn
Copy link
Member

haydn commented Jan 6, 2020

Objective

Move the onMouseMove, onMouseUp and onMouseDown event listeners to the root div in the Editor component.

Rationale

It's pretty common for a user to move the mouse beyond the canvas when panning or dragging to make a selection. Currently, if the user does this and then releases the mouse outside of the canvas they're left in a bit of a broken state.

Notes

We'll need to update canvas.current.getBoundingClientRect() to measure from the root div instead which means we'll also need to add a new ref for the editor (const editor = useRef(null); and ref={editor}).

@Mxchaeltrxn
Copy link
Member

I don't really get the point of this feature. Could you tell me why you want it?

Also, I'm also not really sure how this'll work because currently the canvas treats x === 0, y === 0 (coordinates) as its upper left corner, which makes sense to me. How will this look after tracking mouse movement beyond the canvas?

@haydn
Copy link
Member Author

haydn commented Jan 22, 2020

Sorry, I need to put more details in these issues!

Currently, the onMouseMove event listener is setup on only the canvas (the middle column of the editor’s layout). If you start dragging (to pan the view, for example) and drag beyond the canvas you mouse movement is no longer tracked. Moreover, the onMouseUp event fill only fire if the mouse is over the canvas, so you can get stuck in the wrong mode if you drag outside of the canvas and then release the mouse button.

The solution here might be as simple as moving the event listeners to the root level div that wraps the editor.

@Mxchaeltrxn
Copy link
Member

Sure I'll implement these changes after finishing the validation function issue

@haydn haydn changed the title Track mouse movement beyond the canvas Track mouse activity beyond the canvas Jan 24, 2020
@haydn haydn self-assigned this Jan 27, 2020
@haydn haydn added this to the v0.3 milestone Nov 22, 2020
@haydn haydn linked a pull request Apr 30, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants