tapmodo/Jcrop

Touch not binded on repeat initializations when dynamically generated

Opened this issue · 1 comments

I ran into a problem where initializing jCrop (2.0) on a dynamically generated image would not allow manipulation of the crop region on subsequent attempts after the first instance of jCrop is ran. I figured out that this was the problem:
if (!p.touch) { t.initEvents(); t.shimDragState(); t.shimStageDrag(); p.touch = true; }_

I have edited my copy of Jcrop.js instead to check whether my jcrop_api variable exists, and if not, to continue binding the touch listeners as intended. This seems to do the trick!

if(!jcrop_api){ .... }

function jcropDestroy() {
jcrop_api && jcrop_api.destroy();
$.Jcrop.component.DragState.prototype.touch = null;
}