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

should have callback for cancelSelection event #17

Closed placenamehere closed 11 years ago

placenamehere commented 12 years ago

currently, when cancelSelection() is triggered (such as when the area outside the region is clicked) there isn't a callback that you could use to trigger other cleanup events.

An example where this would be useful is if you want to show some additional UI only when there is an active region. There are existing callback for Start/End so you could use one of those to display the additional UI, but there isn't an appropriate hook to use to then hide it.

Probably as easy as adding an options.onSelectCancel() call in function cancelSelection(), but I haven't tested that solution. If I have time, and wind up that I do need it for this project I'm on, I may for and do just that.

coli commented 12 years ago

Not only that, cancelSelection did not reset the selection correctly.

willemdewit commented 12 years ago

The issue with cancelSelection is fixed in jquery.imgareaselect.dev.js. The onSelectEnd is fired when clicked outside of the selection. In this function you can check if selection.height and selection.width are 0