zurb / twentytwenty

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

Only loads on browser refresh #39

Open sarahkloth opened 9 years ago

sarahkloth commented 9 years ago

I have added the TwentyTwenty plugin for wordpress and it seems to only be loading on browser refresh. Anyone experience this? If you click into any of these you can see what I mean: http://preview.lhkruegerandson.com/before-after-gallery/

bartoszhernas commented 9 years ago

I have the same problem :/

rubenheymans commented 9 years ago

same issue here, maybe use a plugin to load twentytwenty after all images are loaded? I'll test this tomorrow

rubenheymans commented 9 years ago

https://github.com/desandro/imagesloaded

bartoszhernas commented 9 years ago

Issue #31 is the same and they gave a fix in comments :)

rubenheymans commented 9 years ago

Using imageloaded is slightly better than using a timeout, if the images are still not loaded after your timeout it still won't work

        $('.before-after').imagesLoaded( function() {
            $('.before-after').twentytwenty();
        });
tdowgielewicz commented 6 years ago

This made a trick for me:

      <div class="twentytwenty-container" id="images">
        <img id="myImg" src="galeria/slider/<?php echo($id)?>a.jpg" />
        <img id="myImg" src="galeria/slider/<?php echo($id)?>b.jpg" />
      </div>

    <script>

$(window).on('load',function() {
  $("#images").twentytwenty();
});
    </script>