jcrop setSelect problem
Asked Answered
W

1

10

I am having a small issue with setSelect and I cannot figure it out.

I have a code that looks like this:

jQuery('#cropbox1').Jcrop({ 
    setSelect:   [ 157,86,37,49 ],  
    aspectRatio: 151 / 200,
    onChange:    showCoords1,
    onSelect:    showCoords1
    });

However the small box with the cropping is clearly not showing at those positions (for example the 'x' position shown there is 157, but my image is only 300 in width and hence the crop box should appear after half of it, and it's appearing at the start of it.

Any ideas on what could be the problem??

Thank you!!

Wendolyn answered 7/4, 2011 at 1:58 Comment(0)
W
28

Solved, in case anyone has this problem, the third and fourth values in the setSelect params mean the second x and y positions (not the width and height from the first point).

Here's an example that should help illustrate this:

jcrop_api.setSelect([crop.left, crop.top, crop.left + crop.width, crop.top + crop.height]);
Wendolyn answered 10/4, 2011 at 5:16 Comment(2)
I need to specify width and height, but not padding. Do you know how?Archy
@Archy You'll probably need to get the current x2 and y2 positions and use those.Overflight

© 2022 - 2024 — McMap. All rights reserved.