aspect=0 and minSize[0] > boxWidth issue

185 views
Skip to first unread message

simpn

unread,
Dec 21, 2010, 8:36:28 AM12/21/10
to Jcrop Development Discussion
Hi,

I found a bug that causes the selection to get negative x coordinates
and is impossible to resize back to positive widths again. The
following steps reproduces the bug:

First initiate jCrop to have
boxWidth: 640,
bixHeight: 480

Then set, with img.data('Jcrop').setOptions():
aspectRatio: 0
minSize: [700,0]
setSelect: [0,0,1600,1067] //Which is the size of the image to be
cropped

Then the selection is placed at some negative x-coordinates, but
covers the height as it should. The selection stretches all the way to
the right hand side of the cropping area as it should as well.

The problem only occurs for min-widths larger than box-width and
aspect-ratio set to 0.
Don't know if line 234: if (!options.aspectRatio) return getRect();
and the getRect() function may be involved in this.

Note: I have changed jquery.Jcrop.js:1110 to
"setSelect(options.setSelect);" of version v0.9.8

simpn

unread,
Dec 21, 2010, 8:49:34 AM12/21/10
to Jcrop Development Discussion
After further investigation:

When the aspectRatio is set to 0, the selection seems to obey the
_unscaled_ minSize (which is larger than the downscaled image). This
has nothing to do with minsize > boxwidth then, but rather some
missing scaling of the minSize when aspectRatio=0

/Simon

simpn

unread,
Dec 21, 2010, 9:22:47 AM12/21/10
to Jcrop Development Discussion
Okey, seems to be solved now. I'm not sure when xscale and yscale are
set and everything around it, but something like this works:

Change jquery.Jcrop.js:369-372 to:

if (ymin/yscale && (Math.abs(ysize) < ymin/yscale))
y2 = (ysize > 0) ? (y1 + ymin/yscale) : (y1 - ymin/yscale);
if (xmin/xscale && (Math.abs(xsize) < xmin/xscale))
x2 = (xsize > 0) ? (x1 + xmin/xscale) : (x1 - xmin/xscale);

Ie. add /xscale and /yscale to xmin and ymin

/Simon

Kelly Hallman

unread,
Dec 21, 2010, 11:02:06 AM12/21/10
to jcro...@googlegroups.com
Thanks Simon, I will evaluate this change and add it to the source for the next version, which should be released before the first of the year. Thanks for   your work! -Kelly

--
You received this message because you are subscribed to the Google Groups "Jcrop Development Discussion" group.
To post to this group, send email to jcro...@googlegroups.com.
To unsubscribe from this group, send email to jcrop-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jcrop-dev?hl=en.


Reply all
Reply to author
Forward
0 new messages