Guest User

Untitled

a guest
Dec 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. /**
  2. * Redimensiona a imagem de acordo com o tamanho da janela
  3. * @param {jQueryObject} image
  4. * @param {Integer} imgWidth
  5. * @param {Integer} imgHeight
  6. */
  7. function resizeBackground(image, imgWidth, imgHeight){
  8. var win = $(window),
  9. winWidth = win.width(),
  10. winHeight = win.height(),
  11. aspectRatio = winWidth/winHeight;
  12. imgAspectRatio = imgWidth/imgHeight;
  13.  
  14. if ( aspectRatio < imgAspectRatio ) {
  15. image.removeClass('full-width').addClass('full-height');
  16. } else if ( aspectRatio > imgAspectRatio ) {
  17. image.removeClass('full-height').addClass('full-width');
  18. }
  19. }
Add Comment
Please, Sign In to add comment