From 866220f8174b810614d65a5bb65f2a5f4362a90e Mon Sep 17 00:00:00 2001 From: me Date: Sun, 25 Jun 2017 03:00:48 +0900 Subject: [PATCH] when either the width or height of the selected area exceed image size, it is reduced by calculation. --- js/jquery.Jcrop.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/jquery.Jcrop.js b/js/jquery.Jcrop.js index 09b1bcf7..c20b6bff 100644 --- a/js/jquery.Jcrop.js +++ b/js/jquery.Jcrop.js @@ -555,10 +555,12 @@ if (xx < 0) { xx = 0; + x1 = w; h = Math.abs((xx - x1) / aspect); yy = rh < 0 ? y1 - h : h + y1; } else if (xx > boundx) { xx = boundx; + x1 = boundx - w; h = Math.abs((xx - x1) / aspect); yy = rh < 0 ? y1 - h : h + y1; } @@ -568,10 +570,12 @@ yy = rh < 0 ? y1 - h : y1 + h; if (yy < 0) { yy = 0; + y1 = h; w = Math.abs((yy - y1) * aspect); xx = rw < 0 ? x1 - w : w + x1; } else if (yy > boundy) { yy = boundy; + y1 = boundy - h; w = Math.abs(yy - y1) * aspect; xx = rw < 0 ? x1 - w : w + x1; }