Jcrop v0.9.5 Available (bug fixes)

A new version of Jcrop (v0.9.5) is available today. This version fixes a significant design flaw that existed in earlier versions which caused multiple Jcrop instances on the same page to conflict. Thanks to Cihan, Paul, and Firebug.

A new version of Jcrop is available today. This version fixes a significant design flaw that existed in earlier versions which caused multiple Jcrop instances on the same page to conflict.

Prior to this release, applying more than one instance of Jcrop on a page would create a conflict. The widgets would be built and appear to function correctly, but all instances would “control” the latest instance. Even that behavior was not totally evident because Jcrop will preload the image if invoked a certain way, creating a race condition where sometimes one would be initialized later than the other, regardless of the order of instantiation. These facts made tracking down this problem particularly difficult.

In a last resort, browsing the DOM with Firebug allowed me to see the problem. Several methods and variables were being scoped incorrectly, partly due to a misunderstanding I had about the Javascript module pattern. A misunderstanding that was created by the “appears to work because the scope is too large” situation. Always remember “this” can be a common trap.

I’m reminded that Javascript can be a continuous learning experience. I am really glad this got fixed though, because there is no reason you can’t put Jcrop instances all over your page if you want. And there’s no reason those dudes should have been loitering outside of their intended namespace…!!

Thanks to Cihan and Paul, and Firebug.

Tags: ,

20 Responses to “Jcrop v0.9.5 Available (bug fixes)”

  1. Cihan UcarNo Gravatar wrote:

    Thanks for the fix. Works like a charm.

  2. FruitBatInShadesNo Gravatar wrote:

    Fixed the same issues for me too :) Many thanks.

  3. PaulNo Gravatar wrote:

    Thanks, fix worked great! Is there any chance on your next release to possibly return the id of the image along with the coordinates when calling a function with onchange and onselect, as i’m using multiple images, and makes things a lot easier when figuring out which image is related to each of the co-ordinates when using multiple jcrops!

  4. HarryNo Gravatar wrote:

    Olaf – Although this may result in a memory leek, I remove it like this:
    $(‘.jcrop-holder’).before($(‘.jcrop-holder > img’).unbind().css({opacity:”,position:”,display:”}));
    $(‘.jcrop-holder’).remove();

  5. FedericoNo Gravatar wrote:

    Hi, I love this plugin. Exelent work!! I just have a problem and dont know how to resolve it. Does any one know how to make aspectRatio and minSize work together? Because i can make minSize works fine, but, when I add the aspectRation option, I lose the minSize restriction. Can any one help me?

  6. donbNo Gravatar wrote:

    There are a number of unVARed variables in the code. This has produced ‘object does not have property or method’ errors in IE (but not Firefox) when I tried to use jCrop. This evidently is because there is a DOM element on my page named ‘h’ since the error occurs at line 273 (in getFixed()) at the line ‘h = rwa / aspect’

    By using a ‘var h’, the problem went away. But numerous variables are used throughout the code without being declared, so this problem will still be waiting for others to run into it.

  7. adminNo Gravatar wrote:

    @donb: I see that in getFixed() there are a couple of undeclared variables. My bad. The numerous undeclared variables cited in other parts of the code I am not aware of yet. I suspect some of those cases are actually using variables that have been declared in an outer scope. Obviously I understand that all variables must be declared. I’ll look into this and fix any such problems that I find. Thanks!

  8. Trip AlexanderNo Gravatar wrote:

    I am having a strange issue in where FF works like a charm, but IE seems to continuously make requests when you move the mouse in the browser anywhere.

    Has anyone seen this one?

  9. john_leeNo Gravatar wrote:

    你好..博主..

    Jcrop\demos\tutorial3.html 在IE7 有 bug ,

    line:30
    char:5
    错误:参数无效

    首次选中一个框后..然后再点击图片上框外的任何位置,都会出现脚本错误..

  10. EricNo Gravatar wrote:

    seriously, there needs to be a method to unset jCrop.

  11. EricNo Gravatar wrote:

    Ok, the method I’m using to unset jCrop once it’s been set is the following :

    var $jcrop = $(‘.jcrop-holder’);
    $jcrop.empty();
    $jcrop.remove();

    Two steps because IE for some unknown reason acts stupid with just a basic remove.

  12. Tarique SaniNo Gravatar wrote:

    Great plugin – but rather than cropping images I am thinking of using it to implement an Image Notes addition functionality for my ImgNotes plugin found at http://www.sanisoft.com/blog/2009/01/23/img-notes-v02-a-couple-of-bug-fixes-and-some-more/ Thanks for the great work

  13. wasiqNo Gravatar wrote:

    HI

    method of removing the jcrop works fine but when i try to again initilize the jcrop it didnt work any reason why???

  14. shinNo Gravatar wrote:

    Thanks for a great work.

    I have a request for event-handler demo. http://deepliquid.com/projects/Jcrop/demos.php?demo=handler

    I want to input my side and crop box change according to my input. At the moment it shows the size of crop but my input does not change the size of crop.

    Thanks again.

  15. shinNo Gravatar wrote:

    I meant my size, not my side.
    Sorry for my mistake.

  16. WenderNo Gravatar wrote:

    How can i fix the offset position when the jcrop-holder has limited width with overflow:auto?
    To do that test you have to make a container less than the image size with overflow:auto and try to crop some area over the scroll

  17. WenderNo Gravatar wrote:

    Solved turning keySupport option false

    ;)

  18. FreshNo Gravatar wrote:

    Hello, Jcrop works really fine but i got troubles when i try to re-initialize the plugin.

    I got a file input field with a “change” behaviour, i can do my ajax stuff to upload the file and initialize Jcrop but if try to load a different image, the script cant re-initialize Jcrop and the old image is still there (and its ready to crop).

    I’ve tried the unset methods posted in this blog, but it only stop Jcrop to do anything.

    hope i’m clear :)

    Thank You!

  19. lhwparisNo Gravatar wrote:

    this is a very awesome plugin! i agreen that a method to unset or reinitialize the plugin would be very helpful in many situations.

  20. WhiteagleNo Gravatar wrote:

    I think it still requires good “disable” implementation, not only disabling cropping, but returning the original image to all its states. Also, it’d be nice to have the “Enter” handler which fires “onEnd” event (to simulate Photoshop behavior).