Skip to content

Conversation

@c298lee
Copy link
Contributor

@c298lee c298lee commented Mar 18, 2024

Fixes some cropping jank:

  1. Cropping is smoother: previously the event listeners weren't working when the mouse was on the cropping buttons, which was causing the jankiness
  2. Changes the cursor when on the cropping buttons
  3. Increased the minimum size required for cropping so it's easier to resize
Screen.Recording.2024-03-18.at.9.43.25.AM.mov

Fixes getsentry/sentry#67056

@c298lee c298lee requested a review from a team March 18, 2024 13:42
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) 80.74 KB (added)
@sentry/browser (incl. Tracing, Replay) 72.1 KB (added)
@sentry/browser (incl. Tracing, Replay with Canvas) 75.9 KB (added)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 65.66 KB (added)
@sentry/browser (incl. Tracing) 36.7 KB (added)
@sentry/browser (incl. browserTracingIntegration) 36.7 KB (added)
@sentry/browser (incl. feedbackIntegration) 31.36 KB (added)
@sentry/browser (incl. feedbackModalIntegration) 31.48 KB (added)
@sentry/browser (incl. feedbackScreenshotIntegration) 31.49 KB (added)
@sentry/browser (incl. sendFeedback) 27.45 KB (added)
@sentry/browser 22.62 KB (added)
CDN Bundle (incl. Tracing, Replay, Feedback) 75.08 KB (added)
CDN Bundle (incl. Tracing, Replay) 69.92 KB (added)
CDN Bundle (incl. Tracing) 36.28 KB (added)
CDN Bundle 23.99 KB (added)
CDN Bundle (incl. Tracing, Replay) - uncompressed 219.62 KB (added)
CDN Bundle (incl. Tracing) - uncompressed 109.56 KB (added)
CDN Bundle - uncompressed 71.09 KB (added)
@sentry/react (incl. Tracing, Replay) 72.09 KB (added)
@sentry/react 22.64 KB (added)

Comment on lines 136 to 137
const mouseX = e.clientX - cropCanvas.getBoundingClientRect().x;
const mouseY = e.clientY - cropCanvas.getBoundingClientRect().y;
Copy link
Member

@billyvg billyvg Mar 18, 2024

Choose a reason for hiding this comment

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

getBoundingClientRect() forces layout* meaning it'll cause the browser to make a synchronous call. we want to avoid this as much as possible for browser perf. Let's make sure this is only called once.

(* I don't know that this will have an affect since styles don't change between the calls, but something to generally be aware of) -- some reading

Comment on lines 142 to 143
startx: Math.min(Math.max(0, mouseX), prev.endx - 33),
starty: Math.min(Math.max(0, mouseY), prev.endy - 33),
Copy link
Member

Choose a reason for hiding this comment

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

nit, I would expect startx to be startX to be consistent with camelCase

(no need to change it in this PR though)

...prev,
startx: Math.min(e.offsetX, prev.endx - 30),
starty: Math.min(e.offsetY, prev.endy - 30),
startx: Math.min(Math.max(0, mouseX), prev.endx - 33),
Copy link
Member

@billyvg billyvg Mar 18, 2024

Choose a reason for hiding this comment

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

I would move 33 into a constant - it makes it easier to change but also gives you a description of what the number means.

@c298lee c298lee requested review from billyvg and ryan953 March 18, 2024 18:52
Copy link
Member

@billyvg billyvg left a comment

Choose a reason for hiding this comment

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

LGTM

@c298lee c298lee merged commit a99f260 into develop Mar 18, 2024
@c298lee c298lee deleted the cl/cropping-jank branch March 18, 2024 19:57
cadesalaberry pushed a commit to cadesalaberry/sentry-javascript that referenced this pull request Apr 19, 2024
…11165)

Fixes some cropping jank:
1. Cropping is smoother: previously the event listeners weren't working
when the mouse was on the cropping buttons, which was causing the
jankiness
2. Changes the cursor when on the cropping buttons
3. Increased the minimum size required for cropping so it's easier to
resize


https://github.com/getsentry/sentry-javascript/assets/55311782/71b7401e-c9f2-44c2-9f92-64c1c80d24ef

Fixes getsentry/sentry#67056
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 this pull request may close these issues.

Cropping can be challenging

2 participants