wanghaiqing823 / jcrop

Automatically exported from code.google.com/p/jcrop
0 stars 0 forks source link

setSelect doesn't respect trueSize ratio #37

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem ?
1. Follow the method described here :
http://deepliquid.com/content/Jcrop_Sizing_Issues.html : Attach Jcrop on a
php-resized image, and set trueSize option with the real dimension of image
2. Set setSelect to 300x300
3. Set minSize to 300x300
4. We have a first selection of 300x300. Of course we can downsize it, but
the first selection should respect the ratio.

Expected Result :
Respect trueSize ratio. 

Solution :
minSize respect the trueSize ratio. Do same calculation with setSelect ?

Tested on Jcrop 0.9.8 / Firefox 3.6.3 + Firebug / Windows Vista

Original issue reported on code.google.com by denis.tr...@gmail.com on 23 May 2010 at 9:25

GoogleCodeExporter commented 8 years ago
Problem:

var jcrop_api;
jcrop_api = $.Jcrop('#image',{trueSize: [800,600],setSelect: [50,50,500,500]});

Solution:

var jcrop_api;
jcrop_api = $.Jcrop('#image',{trueSize: [800,600]});
jcrop_api.setSelect([50,50,500,500]);

Original comment by koldsga...@gmail.com on 27 Jul 2010 at 12:08

GoogleCodeExporter commented 8 years ago
Thanks for the trick, it works !

Original comment by denis.tr...@gmail.com on 20 Aug 2010 at 11:48

GoogleCodeExporter commented 8 years ago

my jscript r like this.

 jQuery(function() {
        jQuery('#cropbox').Jcrop({
            onSelect:    showCoords,
            bgColor:     'black',
            bgOpacity:   .4,
            setSelect:   [ 100, 100, 50, 50 ],
            aspectRatio: 16 / 9
        });
    });

<div id="mg_dialog" title="image  Manager" style="display: none;">
    <img src="img/product/1.jpg" id="cropbox" />

        <form action="crop.php" method="post" onsubmit="return checkCoords();">
            <input type="hidden" id="x" name="x" />
            <input type="hidden" id="y" name="y" />
            <input type="hidden" id="w" name="w" />
            <input type="hidden" id="h" name="h" />
            <input type="submit" value="Crop Image" />
        </form>
  </div>

my_dialog mean dialog box. when i open dialog. jcrop script is not work.can you 
pls check my code ?

Original comment by koblade...@gmail.com on 11 Mar 2011 at 9:13

GoogleCodeExporter commented 8 years ago
Moving setSelect code below in interfaceUpdate method fixes this problem.

Move following code

        if ('setSelect' in options) {
            setSelect(opt.setSelect);
            Selection.done();
            delete(options.setSelect);
        }

below ymin calculation:

        ymin = options.minSize[1] || 0;

Original comment by sergio.c...@gmail.com on 23 May 2011 at 3:19

GoogleCodeExporter commented 8 years ago
Here is the actual fix. 

https://github.com/jaymecd/Jcrop/commit/8a18bbc7d5594832e58488f4ff463484c460e1d0

Original comment by aaron.sw...@gmail.com on 13 Jan 2012 at 4:18