odyniec / imgareaselect

ImgAreaSelect is a jQuery plugin for selecting a rectangular area of an image. It allows web developers to easily implement image cropping functionality, as well as other user interface features, such as photo notes (like those on Flickr).
http://odyniec.net/projects/imgareaselect/
686 stars 197 forks source link

onSelect events are not triggered when selection is cleared #9

Closed flochtililoch closed 13 years ago

flochtililoch commented 13 years ago

seems like the following code prevent events to be triggered when selection is cleared :

in cancelSelection() function :

/* If this is an API call, callback functions should not be triggered */ if (!this instanceof $.imgAreaSelect) { options.onSelectChange(img, getSelection()); options.onSelectEnd(img, getSelection()); }

reinpk commented 13 years ago

The offending line seems to be the if statement. I think it is merely a typo. I added some parentheses to correct the order of operations on my local copy...

if ( !(this instanceof $.imgAreaSelect) ) {

and it seems to fix the issue.

odyniec commented 13 years ago

I finally had a chance to really look into this, and you're absolutely right -- the parentheses should be there. This is now fixed in the repository (and will be in the next release, which I hope to roll out in about a week). Thanks!