Guest User

Untitled

a guest
Feb 15th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. Template.ImageT.onRendered(
  2. function(){
  3.  
  4. $main = $('#main');
  5. $main.children('.thumb').each(function(){
  6.  
  7. var $this = $(this),
  8. $image = $this.find('.image'), $image_img = $image.children('img'),
  9. x;
  10.  
  11. // No image? Bail.
  12. if ($image.length == 0)
  13. return;
  14.  
  15. // Image.
  16. // This sets the background of the "image" <span> to the image pointed to by its child
  17. // <img> (which is then hidden). Gives us way more flexibility.
  18.  
  19. // Set background.
  20. $image.css('background-image', 'url(' + $image_img.attr('src') + ')');
  21.  
  22. // Set background position.
  23. if (x = $image_img.data('position'))
  24. $image.css('background-position', x);
  25.  
  26. // Hide original img.
  27. $image_img.hide();
  28.  
  29. console.log("IMG HIDDEN")
  30. });
  31.  
  32.  
  33.  
  34. console.log("Ran this!");
  35. });
Add Comment
Please, Sign In to add comment