-
-
Save etyp/48f7e30181f715f3f8c6 to your computer and use it in GitHub Desktop.
Image loads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $bgImages = $('.background-image'); | |
var loadCount = 0; | |
$bgImages.each(function (index) { | |
// Get source based on size | |
var src = isMobile() ? $(this).attr('data-mobile') : $(this).attr('data-desktop') ; | |
// Set source | |
this.src = src; | |
// On image load, call functions | |
$(this).on('load', function () { | |
// Increase load count | |
loadCount++; | |
// If this is the last loaded, do functions | |
if (loadCount === $bgImages.length) { | |
// Do your functions here | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment