zurb / twentytwenty

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

Only shows image when resizing window. #90

Closed Luken1990 closed 6 years ago

Luken1990 commented 6 years ago

Hi everyone,

I know this issue has been posted in the past https://github.com/zurb/twentytwenty/issues/31 and a solution has been given but it appears it does not work in my case. Can someone please take a look at my website and help me with this problem, please.

www.lukenguyen.co.uk

Thanks

rossyoung5 commented 6 years ago

I have been having the same issues. I believe it's a timing issue as to when the twentytwenty() method runs and when the images are loaded and displayed on the page. I used a combination of desandro's imagesloaded library and a custom callback to solve my problem. I'm also calling twentytwenty() multiple times, so I added the .twentytwenty-container class to all my divs using twentytwenty(). Hope this helps!


    function doTwentyTwenty(callback) {
      $('.twentytwenty-container').imagesLoaded(function () {
        $(".twentytwenty-container").twentytwenty();
        callback();
      });
    };
    function resultsUp() {
      resultsContent.slideUp();
    };
    doTwentyTwenty(resultsUp);