scottcheng / cropit

A "customizable crop and zoom" jQuery plugin.
http://scottcheng.github.io/cropit/
MIT License
875 stars 304 forks source link

jQuery 3 is not compatible with this script #251

Open adantart opened 7 years ago

adantart commented 7 years ago

It does not load the image and returns a push function error/warning notification

wapnen commented 7 years ago

yea i'm getting the following exception in my console:

jQuery.Deferred exception: _jquery2.default.event.props is undefined init@http://localhost:8000/js/jquery.cropit.js:274:10 Cropit@http://localhost:8000/js/jquery.cropit.js:194:6 init/<@http://localhost:8000/js/jquery.cropit.js:102:21 each@http://localhost:8000/js/jquery-3.2.1.min.js:2:2713 each@http://localhost:8000/js/jquery-3.2.1.min.js:2:1001 init@http://localhost:8000/js/jquery.cropit.js:96:13 _jquery2.default.fn.cropit@http://localhost:8000/js/jquery.cropit.js:147:13 @http://localhost:8000/js/cropit.js:2:2 j@http://localhost:8000/js/jquery-3.2.1.min.js:2:29997 g/</k<@http://localhost:8000/js/jquery-3.2.1.min.js:2:30313

ghost commented 7 years ago

I am getting the same issue cannot read property 'push' of undefined

kimulisiraj commented 7 years ago

It works fine If You can comment out. // if (this.options.allowDragNDrop) { // _jquery2['default'].event.props.push('dataTransfer'); // } This disables drag and drop

mohandes commented 7 years ago

why developer didn't update cropit for jquery v3?

rsbondi commented 7 years ago

242 seems to work for me, I pointed to the rawgit of this commit and works with old and new version of jquery, at least in my use case

FahriDevZ commented 7 years ago

In jQuery 3 add event like this

jQuery.event.addProp('dataTransfer')
kpmdevgr commented 6 years ago

Also you can solve it by adding allowDragNDrop: false in your cropit call.

@Fahri5567 where should we add this line jQuery.event.addProp('dataTransfer') ?

FahriDevZ commented 6 years ago

@kpmdevgr I change this.

if (this.options.allowDragNDrop) {
    $.event.props.push('dataTransfer');
}

to

if (this.options.allowDragNDrop) {
    if ($.event.props.push) { //if can push
        $.event.props.push('dataTransfer');
    }
    else {
        $.event.addProp('dataTransfer');
    }
}

and build.

But i have problem build cropit with webpack. the problem Error: Cannot find module './Zoomer', because in the file name not Zoomer.js but is zoomer.js. I change import Zoomer from './Zoomer'; to import Zoomer from './zoomer';. and build.

angelogeminiani commented 6 years ago

Is this script still maintained? jQuery 3 compatibility is a must. Does any one created a side project?

kpmdevgr commented 6 years ago

@angelogeminiani i am using it in two web projects with jquery 3, and the only thing i had to change was the drag and drop to be disabled!

ssantanuberaa commented 6 years ago

I have had the same issue.. But disabling drag and drop works.

$('.image-editor').cropit({
    allowDragNDrop: false
});