-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(feedback): Smoother cropping experience and better UI #11165
Conversation
size-limit report 📦
|
const mouseX = e.clientX - cropCanvas.getBoundingClientRect().x; | ||
const mouseY = e.clientY - cropCanvas.getBoundingClientRect().y; |
There was a problem hiding this comment.
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
startx: Math.min(Math.max(0, mouseX), prev.endx - 33), | ||
starty: Math.min(Math.max(0, mouseY), prev.endy - 33), |
There was a problem hiding this comment.
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)
switch (corner) { | ||
case 'topleft': | ||
setCroppingRect(prev => ({ | ||
...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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…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
Fixes some cropping jank:
Screen.Recording.2024-03-18.at.9.43.25.AM.mov
Fixes getsentry/sentry#67056