Skip to content

Commit

Permalink
shrink width of cropper at angles close to 90 degrees.
Browse files Browse the repository at this point in the history
fix thing
  • Loading branch information
mbalaam committed Aug 23, 2019
1 parent dfb6f64 commit 71843fe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
* @param {number} imgHeight height of the src image in pixels
* @param {number} aspect aspect ratio of the crop
*/
export function getCropSize(imgWidth, imgHeight, aspect) {
if (imgWidth >= imgHeight * aspect) {
export function getCropSize(imgWidth, imgHeight, aspect, rotation = 0) {
const { width } = translateSize(imgWidth, imgHeight, rotation)

if (imgWidth >= imgHeight * aspect && width > imgHeight * aspect) {
return {
width: imgHeight * aspect,
height: imgHeight,
}
}

return {
width: imgWidth,
height: imgWidth / aspect,
Expand Down

0 comments on commit 71843fe

Please sign in to comment.