unviel.js difficulty

unviel.js difficulty

hey guys , there is this very simple pluggin called unviel.js for lazy loading . i have used it in a few of my projects but i would like to understand it better a bit . 

below is an example that actually works . 

basically what u do is , just take a gif image and load it in the src attribute and than in another data-src attribute you actually insert the image you actually want to display. 

and than you run the pluggin with the following peice of code : 

  1. $( document ).ready( function () { 
  2.   $( "img" ).unveil(); 
  3. });
below is an example that actually works . 

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Test</title>

  6. <script src="js/jquery.min.js"></script>
  7. <script src="js/jquery.unveil.js"></script>
  8. <script src="js/test.js"></script>



  9. <style>
  10. body{
  11. background:#eee;
  12. }
  13. .main{
  14. width: 800px;
  15. margin: 0 auto;
  16. text-align: center;
  17. }

  18. .main img{
  19. width: 100%;
  20. max-width: 700px;
  21. border: 10px solid #fff;
  22. box-shadow: 1px 1px 10px rgba(0,0,0,.5);

  23.  }

  24. .main figure{
  25. margin-top: 20%;
  26. }

  27. </style>

  28. </head>


  29. <body> 

  30. <div class="main">

  31. <figure>
  32. <img src="img/loading.png" data-src="img/1.png">
  33. <figcaption>I am a caption </figcaption>
  34. </figure>

  35. <figure>
  36. <img src="img/loading.png" data-src="img/2.jpg">
  37. <figcaption>I am a caption </figcaption>
  38. </figure>

  39. <figure>
  40. <img src="img/loading.png" data-src="img/3.jpg">
  41. <figcaption>I am a caption </figcaption>
  42. </figure>


  43. <figure>
  44. <img src="img/loading.png" data-src="img/html5.png">
  45. <figcaption>I am a caption </figcaption>
  46. </figure>

  47. <figure>
  48. <img src="img/loading.png" data-src="img/1.png">
  49. <figcaption>I am a caption </figcaption>
  50. </figure>

  51. <figure>
  52. <img src="img/loading.png" data-src="img/2.jpg">
  53. <figcaption>I am a caption </figcaption>
  54. </figure>

  55. </div>

  56. <script>
  57. $(document).ready(function(){
  58. $('img').unveil(600);
  59. }); // ready
  60. </script>

  61. </body>
  62. </html>                                

if the codes to messy , see it on pastebin . 


now when going through the documentation , i saw a few usages of this pluggin that i did't quite understand . 

  1. eg .  $( "img" ).trigger( "unveil" );

what would that line really do ?? what more can i do , than just lazy load with this pluggin ?? 

its a pritty small pluggin , just liek 50 lines of code , but seems to be pritty handy . 

documentation can be found : docs for unviel

code can be found here : pluggin on git