-
-
Notifications
You must be signed in to change notification settings - Fork 339
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
(Re-add) spin prop #436
(Re-add) spin prop #436
Conversation
Yeah it makes sense for a photo editing type app, I’m good to add the prop will check this out soon |
let radians = Math.abs((degrees * Math.PI) / 180.0); | ||
if ((degrees > -45 && degrees <= 45) || (Math.abs(degrees) > 135 && Math.abs(degrees) <= 180)) { | ||
// Top and Bottom | ||
x = scaledX * Math.cos(radians); |
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.
So this is the condition it normally enters and there is no difference between the previous output (x = (e.clientX - rect.left) / zoom;
) if spin is 0?
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 will merge and check later anyway just curious
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.
Since Math.cos(0) = 1
, when the spin is 0 that will be evaluated as x = scaledX * 1
, so there won't be any difference.
<div className="ReactCrop__drag-handle ord-s" data-ord="s" /> | ||
<div className="ReactCrop__drag-handle ord-sw" data-ord="sw" /> | ||
<div className="ReactCrop__drag-handle ord-w" data-ord="w" /> | ||
<div className="ReactCrop__drag-handle ord-nw" data-ord="nw" style={this.getRotatedCursor("nw", spin)} /> |
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.
Does it make sense to change the inline style more than changing the class name?
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.
My initial thought was to change the inline style, but changing the className might also work.
No, by the looks of it, it should still work the same. Thanks for fixing a redundancy in my code. |
Hi, I apologize for being annoying but I am still having issues using the
rotate
prop. Here you can see that when the image rotates, the ReactCrop container stays in place so the image bounds are cropped.I wasn't able to fix it with CSS, so actually I think that I will stick to the behavior that I had before. I am going to call this prop
spin
since it's more like you are "spinning" the whole crop selection around.I know that it might get confusing to distinguish
scale
/rotate
fromzoom
/spin
, but basically...zoom
/spin
are corrections made to the cropping bounds whenever a parent element is transformed.scale
/rotate
are transformations that are applied directly onto the image.One final note: I had to reset
lastYCrossover
back toyInversed
because it was giving me problems.