tel8618217223380 / jcrop

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

trueSize calculations need Math.ceil #36

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 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 minSize to 300x300
3. Log the x1, x2, y1, y2 like in this example :
http://deepliquid.com/projects/Jcrop/demos.php?demo=handler 
4. Move the selection
5. You often see a drop of 1px in distance calculations (x1 - x2 = 299)  

Expected Result :
Respect minSize distance

Solution :
Using Math.ceil (integer directly superior) in calculations, instead of
Math.round, ParseInt or whatever.

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

Please provide any additional information below.

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

GoogleCodeExporter commented 9 years ago
The bugged line is identified, line 1096, function interfaceUpdate(alt)

Change the lines :

if ('trueSize' in options) {
    xscale = options.trueSize[0] / boundx;
    yscale = options.trueSize[1] / boundy;
}

By the lines :

if ('trueSize' in options) {
    xscale = Math.ceil(options.trueSize[0] / boundx);
    yscale = Math.ceil(options.trueSize[1] / boundy);
}

And the bug will be fixed !

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