Skip to content

feat(region): Add threshold for drawing region#614

Merged
mergify[bot] merged 5 commits intobox:masterfrom
mingzexiao6:add-threshold
Oct 6, 2020
Merged

feat(region): Add threshold for drawing region#614
mergify[bot] merged 5 commits intobox:masterfrom
mingzexiao6:add-threshold

Conversation

@mingzexiao6
Copy link
Contributor

@mingzexiao6 mingzexiao6 commented Oct 2, 2020

threshold-2

TODO:

  • Unit tests
  • Cross-browser testing

@mingzexiao6 mingzexiao6 requested a review from a team October 2, 2020 19:31
@box box deleted a comment from ConradJChan Oct 2, 2020
@mingzexiao6 mingzexiao6 closed this Oct 2, 2020
@mingzexiao6 mingzexiao6 reopened this Oct 2, 2020
@mingzexiao6 mingzexiao6 marked this pull request as ready for review October 5, 2020 22:36
document.removeEventListener('mouseup', handleMouseUp);
};
}, [isDrawing]); // eslint-disable-line react-hooks/exhaustive-deps
}, [drawingStatus]); // eslint-disable-line react-hooks/exhaustive-deps
Copy link
Collaborator

@jstoffan jstoffan Oct 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The major downside here is that we will destroy/recreate the render loop and also remove/re-add the handlers when the status changes from dragging to drawing. Should we only cleanup when in init status? Will that lead to bugs or hanging references?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to add listeners at the beginning of dragging and don't remove them at the end of dragging but remove them at the end of drawing. Unfortunately it doesn't work. The reason is that every render creates a new handleMouseUp function instance. The cleanup callback of drawing cannot remove the listener created in dragging. We can memo all the functions but I think it's better to do in another PR.

@mergify mergify bot merged commit 044b0f0 into box:master Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants