Last active
August 18, 2016 06:19
-
-
Save nishinoshake/4d8d9fd47701be8e7f94 to your computer and use it in GitHub Desktop.
jQueryで画像のプリロード
This file contains hidden or 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
## プロパティcompleteとは |
This file contains hidden or 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 loadImage = function(img) { | |
var defer = new $.Deferred(); | |
$(img).on('load', function() { | |
defer.resolve(this); | |
}).each(function() { | |
if ( this.complete ) { | |
defer.resolve(this); | |
} | |
}); | |
return defer.promise(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment