diff --git a/jquery.collagePlus.js b/jquery.collagePlus.js index 1e25c22..c70eda1 100644 --- a/jquery.collagePlus.js +++ b/jquery.collagePlus.js @@ -300,11 +300,13 @@ * Assign the effect to show the image * Default effect is using jquery and not CSS3 to support more browsers * Wait until the image is loaded to do this + * Fix for Mootools: Instead of load replace it with custom trigger loadc + * on load force a loadc trigger * */ $img - .one('load', function (target) { + .one('loadc', function (target) { return function(){ if( settings.effect == 'default'){ target.animate({opacity: '1'},{duration: settings.fadeSpeed}); @@ -327,9 +329,17 @@ * fix for cached or loaded images * For example if images are loaded in a "window.load" call we need to trigger * the load call again + * Fix for Mootools: Manually triggerring load event causes problem if mootools library is present + * So instead of triggerring load we can trigger a custom event loadc and bind that trigger to either + * image complete (cached) or image load (non-cached) event */ .each(function() { - if(this.complete) $(this).trigger('load'); + if(this.complete) $(this).trigger('loadc'); + else{ + $(this).one('load',function(){ + $(this).trigger('loadc'); + }) + } }); } diff --git a/jquery.collagePlus.min.js b/jquery.collagePlus.min.js index 0102237..09694b1 100644 --- a/jquery.collagePlus.min.js +++ b/jquery.collagePlus.min.js @@ -12,4 +12,4 @@ * http://www.opensource.org/licenses/GPL-2.0 * */ -;(function(e){e.fn.collagePlus=function(t){function n(t,n,i,s){var o=i.padding*(t.length-1)+t.length*t[0][3],u=i.albumWidth-o,a=u/(n-o),f=o,l=na.albumWidth&&s.length!=0){n(s,r-a.padding,a,o);delete r;delete s;r=0;s=[];o+=1}if(a.images.length-1==t&&s.length!=0){n(s,r,a,o);delete r;delete s;r=0;s=[];o+=1}})})};e.fn.collagePlus.defaults={targetHeight:400,fadeSpeed:"fast",display:"inline-block",effect:"default",direction:"vertical",allowPartialLastRow:false}})(jQuery); \ No newline at end of file +;!function(a){a.fn.collagePlus=function(b){function c(b,c,e,f){for(var g=e.padding*(b.length-1)+b.length*b[0][3],h=e.albumWidth-g,i=h/(c-g),j=g,k=c=f?f:10;else var b=9>=l?l+1:10;a.removeClass(function(a,b){return(b.match(/\beffect-\S+/g)||[]).join(" ")}),a.addClass(e.effect),a.addClass("effect-duration-"+b)}}}(m)).each(function(){this.complete?a(this).trigger("loadc"):a(this).one("load",function(){a(this).trigger("loadc")})})}}function d(a,b,c){var d={"margin-bottom":c.padding+"px","margin-right":b?c.padding+"px":"0px",display:c.display,"vertical-align":"bottom",overflow:"hidden"};return a.css(d)}function e(b){$img=a(b);var c=new Array;return c.w=parseFloat($img.css("border-left-width"))+parseFloat($img.css("border-right-width")),c.h=parseFloat($img.css("border-top-width"))+parseFloat($img.css("border-bottom-width")),c}return this.each(function(){var d=0,f=[],g=1,h=a(this);a.fn.collagePlus.defaults.albumWidth=h.width(),a.fn.collagePlus.defaults.padding=parseFloat(h.css("padding-left")),a.fn.collagePlus.defaults.images=h.children();var i=a.extend({},a.fn.collagePlus.defaults,b);i.images.each(function(b){var h=a(this),j=h.is("img")?h:a(this).find("img"),k="undefined"!=typeof j.data("width")?j.data("width"):j.width(),l="undefined"!=typeof j.data("height")?j.data("height"):j.height(),m=e(j);j.data("width",k),j.data("height",l);var n=Math.ceil(k/l*i.targetHeight),o=Math.ceil(i.targetHeight);f.push([this,n,o,m.w,m.h]),d+=n+m.w+i.padding,d>i.albumWidth&&0!=f.length&&(c(f,d-i.padding,i,g),delete d,delete f,d=0,f=[],g+=1),i.images.length-1==b&&0!=f.length&&(c(f,d,i,g),delete d,delete f,d=0,f=[],g+=1)})})},a.fn.collagePlus.defaults={targetHeight:400,fadeSpeed:"fast",display:"inline-block",effect:"default",direction:"vertical",allowPartialLastRow:!1}}(jQuery); \ No newline at end of file