feat(feedback): Implement highlighting and hiding controls for screenshots #15951
+404
−744
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I should write that there are like 3 separate systems inside the
ScreenshotEditor
component, all working with the same data and helpers really, but each easy to spot and understand on their own.The end-goal is to have the correct thing rendered into
outputBuffer
(which is an argument to the component, but it's used for outputting data) and also render into theforeground
andbackground
.useLayoutEffect
anduseEffect
calls. These basically depend on thescreenshot
prop &drawCommands
state. When those change we're basically re-sizing and re-rendering into our canvases.handleMouseDown
. We callgetBoundingClientRect
and use offsetX/offsetY for a consistent frame if reference when doing mouse coordinates. From in here we don't update any react state until onMouseUp happens, so the re-rendering onMouseMove is really fast to execute, and really easy to understand.drawCommands
stuff andscaleFactor
. All the drawCommands in state/memory are using an x/y coordinate system based on the size of the original screenshot. So when we call paintForeground it's really easy. But when we want to add<div>
elements to the page we have to scale the sizes. This helps with window resize, and helps to consolidate when/where we convert from one x/y coordinate system to another.The resulting feedbacks are in the correct dpi, and have boxes draw using the same DPI.
Related to #15424
Iteration on top of develop...ryan953/feedback-highlight-mask-ref
Fixes getsentry/sentry#69786