zurb / twentytwenty

jQuery Plugin to Compare Images
ISC License
1.27k stars 295 forks source link

TwentyTwenty doesn't work with JQuery 3.1.0? #63

Closed jamesaslett1985 closed 7 years ago

jamesaslett1985 commented 8 years ago

Hi,

I have just upgraded from JQuery 1.11.1 to 3.1.0 and it appears to have broken TwentyTwenty. Should it work with 3.1.0?

Many thanks

calebfaruki commented 8 years ago

You should include JS error code.

In my case, the .indexOf() function returned undefined.

I worked around this issue by downgrading from jQuery 3.1.0 to 2.1.0.

Here is a codepen replicating the error: http://codepen.io/baph0mt/pen/dpJWEg

And the resulting console error output.

pen.js:580 
    Uncaught TypeError: Cannot read property 'indexOf' of undefined(anonymous function)
        @ pen.js:580(anonymous function)
        @ pen.js:584(anonymous function)
        @ pen.js:31(anonymous function)
        @ pen.js:33
phuphighter commented 7 years ago

I know this is old but I solved this by using https://github.com/stephband/jquery.event.move.

And then:

$(window).on("load", function(){
    $("#container1").twentytwenty();
});
danieledistanio commented 7 years ago

Thanks Jhonny! It is now working for me.

I will only add that in case you're using multiple instances your code should be:

$(window).on("load", function(){ $(".twentytwenty-container").twentytwenty(); });

Bye!

raphaeleidus commented 7 years ago

The newest version available supports jquery3 primarily by updating jquery.event.move