From fa3fe9df9fe1dd6ebddc66708adee75747e78179 Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Wed, 12 Jan 2011 08:24:34 -0500 Subject: [PATCH] src : add imagesLoaded plugin by Paul Irish --- src/jquery.isotope.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/jquery.isotope.js b/src/jquery.isotope.js index 4e5f919..1b8c3db 100755 --- a/src/jquery.isotope.js +++ b/src/jquery.isotope.js @@ -886,6 +886,35 @@ + // mit license. paul irish. 2010. + // webkit fix from Oren Solomianik. thx! + + // callback function is passed the last image to load + // as an argument, and the collection as `this` + + + $.fn.imagesLoaded = function(callback){ + var elems = this.find('img'), + len = elems.length, + _this = this; + + elems.bind('load',function(){ + if (--len <= 0){ + callback.call( _this ); + } + }).each(function(){ + // cached images don't fire load sometimes, so we reset src. + if (this.complete || this.complete === undefined){ + var src = this.src; + // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f + // data uri bypasses webkit log warning (thx doug jones) + this.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="; + this.src = src; + } + }); + + return this; + };