Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated to 0.2

  • Loading branch information...
commit 81edd14180ea8509b5a8275309e3bad2631b2b70 1 parent 764248d
Jason English authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 jquery.flex.min.js
10 jquery.flex.min.js
View
@@ -1 +1,9 @@
-"filter"in Array.prototype||(Array.prototype.filter=function(e,t){"use strict";var n=[],r;for(var i=0,s=this.length;i<s;i++)i in this&&e.call(t,r=this[i],i,this)&&n.push(r);return n}),function(e,t,n,r){"use strict";function s(t,n){this.version="0.1",this.element=e(t),this.tiles=this.element.find("a"),this.options=e.extend({},i,n),this.list=[],this.cache=[],this.init()}var i={duration:300,padding:10,threshhold:50};s.prototype.init=function(){this.buildCache(),this.createEvents()},s.prototype.createCacheObj=function(e){return{elm:e,defaults:{width:parseInt(e.css("width"),10),height:parseInt(e.css("height"),10),left:parseInt(e.css("left"),10),top:parseInt(e.css("top"),10)},expanded:{width:parseInt(e.attr("width"),10),height:parseInt(e.attr("height"),10),left:parseInt(e.css("left"),10),top:parseInt(e.css("top"),10)}}},s.prototype.buildCache=function(){var t=this.tiles,n,r=t.length;for(var i=0;i<r;i++)n=e(t[i]),this.list.push(this.createCacheObj(n)),this.cache[i]=this.list[this.list.length-1],n.data("flex-cache",i)},s.prototype.createEvents=function(){var e=this;this.tiles.on("mouseenter",function(){e.change(this),e.animate("grow")}).on("mouseleave",function(){e.animate("shrink")})},s.prototype.getCache=function(t){return this.cache[e(t).data("flex-cache")]},s.prototype.animate=function(e){var t={queue:!1,duration:300},n=0;if(e==="grow")for(;n<this.changes.length;n++)this.changes[n].elm.dequeue().animate(this.changes[n].change,t);else for(;n<this.list.length;n++)this.list[n].elm.dequeue().animate(this.list[n].defaults,t),delete this.list[n].change,delete this.list[n].start,delete this.list[n].adjusted},s.prototype.getPositions=function(e){return[[e.left,e.left+e.width],[e.top,e.top+e.height]]},s.prototype.comparePositions=function(e,t){var n,r;return n=e[0]<t[0]?e:t,r=e[0]<t[0]?t:e,n[1]>r[0]||n[0]===r[0]},s.prototype.overlaps=function(e,t){var n=this.getPositions(e.change),r=this.getPositions(t.defaults);return this.comparePositions(n[0],r[0])&&this.comparePositions(n[1],r[1])},s.prototype.intersectors=function(e){var t=this.list,n=[];for(var r=0;r<t.length;r++)t[r].elm[0]!==e.elm[0]&&this.overlaps(e,t[r])&&n.push(t[r]);return n},s.prototype.adjust=function(e,t){var n,r,i,s,o={},u=t,a=!1,f=this.options.threshhold,l=this.options.padding,c=e.defaults.top>u.defaults.top+u.defaults.height,h=e.defaults.top+e.defaults.height<u.defaults.top,p=e.defaults.left<u.defaults.left,d=e.defaults.left>u.defaults.left+u.defaults.width,v=u.defaults.left+u.defaults.width>e.defaults.left;return h||c?n=e.defaults.width:d?n=e.defaults.left+e.defaults.width-(u.change.left+u.change.width)-l:n=u.change.width-e.defaults.width+l,n<f&&(n=f,a=!0),c||h?r=e.defaults.height+e.defaults.top-u.change.height-l:d?r=e.defaults.height:r=u.change.height-e.defaults.height,r<f&&(r=f,a=!0),c||h?i=e.defaults.left:d?i=u.change.left+u.change.width+l:i=u.change.left+u.change.width+l,c?s=u.change.top+u.change.height+l:s=e.defaults.top,[{width:n,height:r,left:i,top:s},a]},s.prototype.recursion=function(e){var t,n,r=this.times,i=this.changes,s,o=0,u=i.length,a,f,l=0,c;for(;o<u;o++){s=i[o];if(e&&s.elm[0]===e.elm[0]){s.start=!0,s.change=s.expanded,l++;break}if(s.change&&!s.adjusted){this.first||(this.first=!0,s.adjusted=!0),a=this.intersectors(s);for(var h=0,p=a.length;h<p;h++){f=a[h];if(!f.start&&f.elm[0]!==s.elm[0]){c=this.adjust(f,s);for(var d=0;d<i.length;d++)if(f.elm[0]===i[d].elm[0]&&!i[d].adjusted){t=i[d],n=c[0],t.change&&t.change.width===n.width&&t.change.height===n.height&&t.change.left===n.left&&t.change.top===n.top?i[d].adjusted=!0:(i[d].change=c[0],l++);break}}}}}l&&this.recursion()},s.prototype.change=function(t){var n=this.getCache(t),r=[];this.changes=e.extend(!0,[],this.list),this.first=null,this.recursion(n),this.changes=this.changes.filter(function(e){if(e.change)return e})},e.fn.flex=function(t){var n=this.data("flex"),r=t||{};return n?n:(this.each(function(){e(this).data("flex",new s(this,r))}),r.api?n:this)}}(jQuery,window,document)
+/**
+ * jQuery Flex v0.2
+ * A fluid asymmetrical animated grid plugin for jQuery
+ * http://jsonenglish.com
+ *
+ * Licensed under the MIT license.
+ * Copyright 2012 Jason English
+ */
+(function(b,d){var c={duration:300,padding:10,threshhold:50};function a(f,e){this.version="0.2";this.element=b(f);this.tiles=this.element.find("a");this.options=b.extend({},c,e);this.list=[];this.cache=[];this.init()}a.prototype.init=function(){this.buildCache();this.createEvents()};a.prototype.createCacheObj=function(e){return{elm:e,defaults:{width:e.width(),height:e.height(),left:parseInt(e.css("left"),10),top:parseInt(e.css("top"),10)},expanded:{width:parseInt(e.attr("width"),10),height:parseInt(e.attr("height"),10),left:parseInt(e.css("left"),10),top:parseInt(e.css("top"),10)}}};a.prototype.buildCache=function(){var g=this.tiles,h,f=g.length;for(var e=0;e<f;e++){h=b(g[e]);this.list.push(this.createCacheObj(h));this.cache[e]=this.list[this.list.length-1];h.data("flex-cache",e)}};a.prototype.createEvents=function(){var e=this;this.tiles.on("mouseenter",function(){e.change(this);e.animate("grow")}).on("mouseleave",function(){e.animate("shrink")})};a.prototype.getCache=function(e){return this.cache[b(e).data("flex-cache")]};a.prototype.animate=function(g){var f={queue:false,duration:300},e=0;if(g==="grow"){for(;e<this.changes.length;e++){this.changes[e].elm.dequeue().animate(this.changes[e].change,f)}}else{for(;e<this.list.length;e++){this.list[e].elm.dequeue().animate(this.list[e].defaults,f);delete this.list[e].change;delete this.list[e].start;delete this.list[e].adjusted}}};a.prototype.getPositions=function(e){return[[e.left,(e.left+e.width)],[e.top,e.top+e.height]]};a.prototype.comparePositions=function(h,g){var f,e;f=h[0]<=g[0]?h:g;e=h[0]<=g[0]?g:h;return f[1]>=e[0]||f[0]===e[0]};a.prototype.overlaps=function(f,e){var h=this.getPositions(f.change),g=this.getPositions(e.change||e.defaults);return this.comparePositions(h[0],g[0])&&this.comparePositions(h[1],g[1])};a.prototype.intersectors=function(h,f){var g=(f)?this.changes:this.list,i=[];for(var e=0;e<g.length;e++){if(g[e].elm[0]!==h.elm[0]&&!g[e].start&&!g[e].adjusted&&this.overlaps(h,g[e])){i.push(g[e])}}return i};a.prototype.adjust=function(f,u){var s,k,i,v,p={},r=u,o=false,g=this.options.threshhold,q=this.options.padding,n=f.defaults.top>r.defaults.top+r.defaults.height,m=f.defaults.top+f.defaults.height<r.defaults.top,j=f.defaults.left<r.defaults.left,e=f.defaults.left>r.defaults.left+r.defaults.width;if(m||n){s=f.defaults.width}else{if(e){s=f.defaults.left+f.defaults.width-(r.change.left+r.change.width)-q}else{s=r.change.width-f.defaults.width+q}}if(s<g){s=g;o=true}if(n||m){k=f.defaults.height+f.defaults.top-r.change.height-q}else{if(e){k=f.defaults.height}else{k=r.change.height-f.defaults.height}}if(k<g){k=g;o=true}if(n||m){i=f.defaults.left}else{if(e){i=(r.change.left+r.change.width)+q}else{i=r.change.left+r.change.width+q}}if(n){v=r.change.top+r.change.height+q}else{v=f.defaults.top}return[{width:s,height:k,left:i,top:v},o]};a.prototype.recursion=function(f){var m,n,s,e,j,g,o,h=this.times,r=this.changes,l,q=0,u=r.length,k=0;for(;q<u;q++){l=r[q];if(f){if(l.elm[0]===f.elm[0]){l.start=true;l.change=l.expanded;k++;break}}if(l.change&&!l.adjusted){if(!this.first){this.first=true;l.adjusted=true}j=this.intersectors(l,true);for(o=0;o<j.length;o++){e=j[o];if(!e.start&&e.elm[0]!==l.elm[0]){s=this.adjust(e,l);for(g=0;g<r.length;g++){if(e.elm[0]===r[g].elm[0]&&!r[g].adjusted){m=r[g];n=s[0];if(m.change&&(m.change.width===n.width&&m.change.height===n.height&&m.change.left===n.left&&m.change.top===n.top)){r[g].adjusted=true}else{r[g].change=s[0];k++}break}}}}}}if(k){this.recursion()}};a.prototype.change=function(g){var f=this.getCache(g),e=[];this.changes=b.extend(true,[],this.list);this.first=null;this.recursion(f)};b.fn.flex=function(e){var g=this.data("flex"),f=e||{};if(g){return g}this.each(function(){b(this).data("flex",new a(this,f))});return f.api?g:this}})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.