Mostly IE fixes

pull/56/head
Glen Cheney 11 years ago
parent 92239c6e49
commit 5724739328

@ -41,7 +41,7 @@
<h3 id="columns">How column widths work</h3>
<p>The <code>columnWidth</code> option is used to calculate the column width. You have several options:</p>
<ol>
<li>Use a <strong>sizer</strong> element. This is the easest way to specify column and gutter widths. You can use an element or an element wrapped in jQuery. The column and gutter widths will be measured using this element. The <code>sizer</code> option is an alias for <code>columnWidth</code>. See <a href="{% post_url demos/2013-05-01-basic %}">a demo</a> using a sizer element or <a href="{{ site.url }}/js/demos/homepage.js">look at js file</a> for the sizer demo</a>.</li>
<li>Use a <strong>sizer</strong> element. This is the easest way to specify column and gutter widths. You can use an element or an element wrapped in jQuery. The column and gutter widths will be measured using this element. The <code>sizer</code> option is an alias for <code>columnWidth</code>. See <a href="{% post_url demos/2013-05-01-basic %}">a demo</a> using a sizer element or <a href="{{ site.url }}/js/demos/homepage.js">look at the js file</a> for the sizer demo.</li>
<li>Use a <strong>function</strong>. When a function is used, its first parameter will be the width of the shuffle element. You need to return the column width for shuffle to use (in pixels).</li>
<li>A <strong>number</strong>. This will explicitly set the column width to your number (in pixels).</li>
<li>By default, shuffle will use jQuery's <code class="language-javascript">outerWidth(true)</code> to calculate the column width of the first item and use that value.</li>

@ -107,8 +107,8 @@ button {
$size: 20px;
// Circle and check
&.active::before,
&.active::after {
&.active:before,
&.active:after {
content: '';
position: absolute;
top: 50%;
@ -122,21 +122,21 @@ button {
}
// Circle
&::before {
&:before {
background-color: $gray10;
border-radius: 50%;
}
// Check
&::after {
&:after {
background-size: 60%;
background-position: center center;
background-repeat: no-repeat;
background-image: url(../img/check.svg);
}
&.active::before,
&.active::after {
&.active:before,
&.active:after {
opacity: 1;
}
}

@ -5,11 +5,11 @@ body {
// Links
a {
text-decoration: none;
&,
&:visited {
color: $river;
text-decoration: none;
}
&:hover {

@ -25,9 +25,11 @@
.shape-up {
position: relative;
overflow: hidden;
}
.shape {
position: relative;
margin-left: 0;
margin-top: 10px;
@ -97,6 +99,22 @@ $leftOver: $triangleSize - $fullSideWidth;
}
// IE8 filter alpha wasn't working with the positioning stuff
.lt-ie9 .shape {
.keep-ratio {
position: static;
width: 100%;
height: 250px;
overflow: visible;
padding-bottom: 0;
}
.shape__inner {
position: static;
width: 100%;
height: 100%;
}
}
@media (min-width: 1200px) {

@ -70,6 +70,7 @@ $itemHeight: 220px;
*/
.shuffle--container {
position: relative;
overflow: hidden;
}
.shuffle--fluid .shuffle__sizer {

@ -17,9 +17,11 @@
.shape-up {
position: relative;
overflow: hidden;
}
.shape {
position: relative;
margin-left: 0;
margin-top: 10px;
}
@ -76,6 +78,19 @@
background-color: transparent;
}
.lt-ie9 .shape .keep-ratio {
position: static;
width: 100%;
height: 250px;
overflow: visible;
padding-bottom: 0;
}
.lt-ie9 .shape .shape__inner {
position: static;
width: 100%;
height: 100%;
}
@media (min-width: 1200px) {
.shape--triangle .shape__space {
padding-top: 18px;

@ -52,6 +52,7 @@
*/
.shuffle--container {
position: relative;
overflow: hidden;
}
.shuffle--fluid .shuffle__sizer {

@ -363,9 +363,11 @@ body {
color: #5d6d77;
}
a {
text-decoration: none;
}
a, a:visited {
color: #3498db;
text-decoration: none;
}
a:hover {
text-decoration: underline;
@ -2121,7 +2123,7 @@ button:active {
.filter-group .btn {
position: relative;
}
.filter-group .btn.active::before, .filter-group .btn.active::after {
.filter-group .btn.active:before, .filter-group .btn.active:after {
content: '';
position: absolute;
top: 50%;
@ -2133,17 +2135,17 @@ button:active {
opacity: 0;
transition: .2s;
}
.filter-group .btn::before {
.filter-group .btn:before {
background-color: #2c3e50;
border-radius: 50%;
}
.filter-group .btn::after {
.filter-group .btn:after {
background-size: 60%;
background-position: center center;
background-repeat: no-repeat;
background-image: url(../img/check.svg);
}
.filter-group .btn.active::before, .filter-group .btn.active::after {
.filter-group .btn.active:before, .filter-group .btn.active:after {
opacity: 1;
}

@ -138,8 +138,6 @@ var Shuffle = function( $container, options ) {
Shuffle.prototype = {
constructor: Shuffle,
_init : function() {
var self = this,
containerCSS,
@ -1066,6 +1064,7 @@ Shuffle.settings = {
top: 0,
left: 0
},
offset: { top: 0, left: 0 },
revealAppendedDelay: 300,
keepSorted : true, // Keep sorted when shuffling/layout
enabled: true,

@ -29,23 +29,60 @@
* @version 2.0
* @date 07/05/13
*/
(function(e,p,h){e.fn.sorted=function(a){var b=e.extend({},e.fn.sorted.defaults,a);a=this.get();var c=!1;if(!a.length)return[];if(b.randomize)return e.fn.sorted.randomize(a);b.by!==e.noop&&(null!==b.by&&b.by!==h)&&a.sort(function(a,f){if(c)return 0;var g=b.by(e(a)),k=b.by(e(f));return g===h&&k===h?(c=!0,0):"sortFirst"===g||"sortLast"===k?-1:"sortLast"===g||"sortFirst"===k?1:g<k?-1:g>k?1:0});if(c)return this.get();b.reverse&&a.reverse();return a};e.fn.sorted.defaults={reverse:!1,by:null,randomize:!1};
e.fn.sorted.randomize=function(a){var b=a.length,c,d;if(!b)return a;for(;--b;)d=Math.floor(Math.random()*(b+1)),c=a[d],a[d]=a[b],a[b]=c;return a};var q=0,l=function(a,b){e.extend(this,l.options,b,l.settings);this.$container=a;this.$window=e(window);this.unique="shuffle_"+q++;this._fire("loading");this._init();this._fire("done")};l.prototype={constructor:l,_init:function(){var a=this,b,c=e.proxy(a._onResize,a);b=a.throttle?a.throttle(a.throttleTime,c):c;c=a.initialSort?a.initialSort:null;a._setVars();
a._resetCols();a._addClasses();a._initItems();a.$window.on("resize.shuffle."+a.unique,b);b=a.$container.css(["paddingLeft","paddingRight","position","width"]);"static"===b.position&&a.$container.css("position","relative");a.offset={left:parseInt(b.paddingLeft,10)||0,top:parseInt(b.paddingTop,10)||0};a._setColumns(parseInt(b.width,10));a.shuffle(a.group,c);a.supported&&setTimeout(function(){a._setTransitions();a.$container[0].style[a.transitionName]="height "+a.speed+"ms "+a.easing},0)},_addClasses:function(){this.$container.addClass("shuffle");
this.$items.addClass("shuffle-item filtered");return this},_setVars:function(){this.$items=this._getItems();this.transitionName=this.prefixed("transition");this.transitionDelayName=this.prefixed("transitionDelay");this.transitionDuration=this.prefixed("transitionDuration");this.transform=this.getPrefixed("transform");this.transitionend={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"MSTransitionEnd",transition:"transitionend"}[this.transitionName];
this.isFluid=this.columnWidth&&"function"===typeof this.columnWidth;0===this.columnWidth&&null!==this.sizer&&(this.columnWidth=this.sizer);"string"===typeof this.columnWidth?this.$sizer=this.$container.find(this.columnWidth):this.columnWidth&&this.columnWidth.nodeType&&1===this.columnWidth.nodeType?this.$sizer=e(this.columnWidth):this.columnWidth&&this.columnWidth.jquery&&(this.$sizer=this.columnWidth);this.$sizer&&this.$sizer.length&&(this.useSizer=!0,this.sizer=this.$sizer[0]);return this},_filter:function(a,
b){var c=this,d=b!==h?b:c.$items,f=e();a=a||c.lastFilter;c._fire("filter");e.isFunction(a)?d.each(function(){var b=e(this);a.call(b[0],b,c)&&(f=f.add(b))}):(c.group=a,"all"!==a?d.each(function(){var b=e(this),d=b.data("groups"),d=c.delimeter&&!e.isArray(d)?d.split(c.delimeter):d;-1<e.inArray(a,d)&&(f=f.add(b))}):f=d);c._toggleFilterClasses(d,f);b=d=null;return f},_toggleFilterClasses:function(a,b){a.filter(b).each(function(){var a=e(this);a.hasClass("concealed")&&a.removeClass("concealed");a.hasClass("filtered")||
a.addClass("filtered")});a.not(b).each(function(){var a=e(this);a.hasClass("concealed")||a.addClass("concealed");a.hasClass("filtered")&&a.removeClass("filtered")})},_initItems:function(a){a=a||this.$items;return a.css(this.itemCss)},_updateItemCount:function(){this.visibleItems=this.$items.filter(".filtered").length;return this},_setTransition:function(a){a.style[this.transitionName]=this.transform+" "+this.speed+"ms "+this.easing+", opacity "+this.speed+"ms "+this.easing;return a},_setTransitions:function(a){var b=
this;a=a||b.$items;a.each(function(){b._setTransition(this)});return b},_setSequentialDelay:function(a){var b=this;b.supported&&e.each(a,function(a){this.style[b.transitionDelayName]="0ms,"+(a+1)*b.sequentialFadeDelay+"ms";e(this).one(b.transitionend,function(){this.style[b.transitionDelayName]="0ms"})})},_getItems:function(){return this.$container.children(this.itemSelector)},_getPreciseDimension:function(a,b){var c;c=window.getComputedStyle?window.getComputedStyle(a,null)[b]:e(a).css(b);return parseFloat(c)},
_setColumns:function(a){a=a||this.$container.width();var b="function"===typeof this.gutterWidth?this.gutterWidth(a):this.useSizer?this._getPreciseDimension(this.sizer,"marginLeft"):this.gutterWidth;this.colWidth=(this.colWidth=this.isFluid?this.columnWidth(a):this.useSizer?this._getPreciseDimension(this.sizer,"width"):this.columnWidth||this.$items.outerWidth(!0)||a)||a;this.colWidth+=b;b=(a+b)/this.colWidth;0.01>Math.ceil(b)-b&&(b=Math.ceil(b));this.cols=Math.floor(b);this.cols=Math.max(this.cols,
1);this.containerWidth=a},_setContainerSize:function(){var a=Math.max.apply(Math,this.colYs);this.$container.css("height",a+"px")},_fire:function(a,b){this.$container.trigger(a+".shuffle",b&&b.length?b:[this])},_layout:function(a,b,c,d){var f=this;b=b||f.filterEnd;f.layoutTransitionEnded=!1;e.each(a,function(g){g=e(a[g]);var k=Math.ceil(g.outerWidth(!0)/f.colWidth),k=Math.min(k,f.cols);if(1===k)f._placeItem(g,f.colYs,b,c,d);else{var m=f.cols+1-k,h=[],l,n;for(n=0;n<m;n++)l=f.colYs.slice(n,n+k),h[n]=
Math.max.apply(Math,l);f._placeItem(g,h,b,c,d)}});f._processStyleQueue();f._setContainerSize()},_resetCols:function(){var a=this.cols;for(this.colYs=[];a--;)this.colYs.push(0)},_reLayout:function(a,b){this._resetCols();this.keepSorted&&this.lastSort?this.sort(this.lastSort,!0,b):this._layout(this.$items.filter(".filtered").get(),this.filterEnd,b)},_placeItem:function(a,b,c,d,e){for(var g=Math.min.apply(Math,b),k=0,m=0,h=b.length;m<h;m++)if(b[m]>=g-this.buffer&&b[m]<=g+this.buffer){k=m;break}b=this.colWidth*
k;var l=g;b=Math.round(b+this.offset.left);l=Math.round(l+this.offset.top);a.data({x:b,y:l});g+=a.outerHeight(!0);h=this.cols+1-h;for(m=0;m<h;m++)this.colYs[k+m]=g;a={from:"layout",$this:a,x:b,y:l,scale:1};d?a.skipTransition=!0:(a.opacity=1,a.callback=c);e&&(a.opacity=0);this.styleQueue.push(a)},_shrink:function(a,b){var c=this,d=a||c.$items.filter(".concealed"),f={},g=b||c.shrinkEnd;d.length&&(c._fire("shrink"),c.shrinkTransitionEnded=!1,d.each(function(){var a=e(this),b=a.data();f={from:"shrink",
$this:a,x:b.x,y:b.y,scale:0.001,opacity:0,callback:g};c.styleQueue.push(f)}))},_onResize:function(){var a;this.enabled&&!this.destroyed&&(a=this.$container.width(),a!==this.containerWidth&&this.resized())},setPrefixedCss:function(a,b,c){a.css(this.prefixed(b),c)},getPrefixed:function(a){return(a=this.prefixed(a))?a.replace(/([A-Z])/g,function(a,c){return"-"+c.toLowerCase()}).replace(/^ms-/,"-ms-"):a},transition:function(a){var b=this,c,d=function(){b.layoutTransitionEnded||"layout"!==a.from?b.shrinkTransitionEnded||
"shrink"!==a.from||(a.callback.call(b),b.shrinkTransitionEnded=!0):(b._fire("layout"),a.callback.call(b),b.layoutTransitionEnded=!0)};a.callback=a.callback||e.noop;b.supported?(a.scale===h&&(a.scale=1),c=b.threeD?"translate3d("+a.x+"px, "+a.y+"px, 0) scale3d("+a.scale+", "+a.scale+", 1)":"translate("+a.x+"px, "+a.y+"px) scale("+a.scale+", "+a.scale+")",a.x!==h&&b.setPrefixedCss(a.$this,"transform",c),a.opacity!==h&&a.$this.css("opacity",a.opacity),a.$this.one(b.transitionend,d)):(c={left:a.x,top:a.y,
opacity:a.opacity},a.$this.stop(!0).animate(c,b.speed,"swing",d))},_processStyleQueue:function(){var a=this;e.each(a.styleQueue,function(b,c){c.skipTransition?a._skipTransition(c.$this[0],function(){a.transition(c)}):a.transition(c)});a.styleQueue.length=0},shrinkEnd:function(){this._fire("shrunk")},filterEnd:function(){this._fire("filtered")},sortEnd:function(){this._fire("sorted")},_skipTransition:function(a,b,c){var d=this.transitionDuration,f=a.style[d];a.style[d]="0ms";e.isFunction(b)?b():a.style[b]=
c;a.style[d]=f},_addItems:function(a,b,c){var d;this.supported||(b=!1);a.addClass("shuffle-item");this._initItems(a);this._setTransitions(a);this.$items=this._getItems();a.css("opacity",0);a=this._filter(h,a);d=a.get();this._updateItemCount();b?(this._layout(d,null,!0,!0),c&&this._setSequentialDelay(a),this._revealAppended(a)):this._layout(d)},_revealAppended:function(a){var b=this;setTimeout(function(){a.each(function(a,d){b.transition({from:"reveal",$this:e(d),opacity:1})})},b.revealAppendedDelay)},
shuffle:function(a,b){this.enabled&&(a||(a="all"),this._filter(a),this.lastFilter=a,this._updateItemCount(),this._resetCols(),this._shrink(),b&&(this.lastSort=b),this._reLayout())},sort:function(a,b,c){var d=this,e=d.$items.filter(".filtered").sorted(a);b||d._resetCols();d._layout(e,function(){b&&d.filterEnd();d.sortEnd()},c);d.lastSort=a},resized:function(a){this.enabled&&(a||this._setColumns(),this._reLayout())},layout:function(){this.update(!0)},update:function(a){this.resized(a)},appended:function(a,
b,c){this._addItems(a,!1===b?!1:!0,!1===c?!1:!0)},disable:function(){this.enabled=!1},enable:function(a){this.enabled=!0;!1!==a&&this.update()},remove:function(a){if(a.length&&a.jquery)return this._shrink(a,function(){var b=this;a.remove();setTimeout(function(){b.$items=b._getItems();b.layout();b._updateItemCount();b._fire("removed",[a,b]);a=null},0)}),this._processStyleQueue(),this},destroy:function(){this.$window.off("."+this.unique);this.$container.removeClass("shuffle").removeAttr("style").removeData("shuffle");
this.$items.removeAttr("style").removeClass("concealed filtered shuffle-item");this.destroyed=!0}};l.options={group:"all",speed:250,easing:"ease-out",itemSelector:"",sizer:null,gutterWidth:0,columnWidth:0,delimeter:null,buffer:0,initialSort:null,throttle:e.throttle||null,throttleTime:300,sequentialFadeDelay:150,supported:p.csstransforms&&p.csstransitions};l.settings={$sizer:null,useSizer:!1,itemCss:{position:"absolute",top:0,left:0},revealAppendedDelay:300,keepSorted:!0,enabled:!0,destroyed:!1,styleQueue:[],
prefixed:p.prefixed,threeD:p.csstransforms3d};e.fn.shuffle=function(a){var b=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=e(this),d=c.data("shuffle");d||(d=new l(c,a),c.data("shuffle",d));"string"===typeof a&&d[a]&&d[a].apply(d,b)})}})(jQuery,Modernizr);
!function(t,e,i){"use strict"
t.fn.sorted=function(e){var n=t.extend({},t.fn.sorted.defaults,e),s=this.get(),r=!1
return s.length?n.randomize?t.fn.sorted.randomize(s):(n.by!==t.noop&&null!==n.by&&n.by!==i&&s.sort(function(e,s){if(r)return 0
var o=n.by(t(e)),a=n.by(t(s))
return o===i&&a===i?(r=!0,0):"sortFirst"===o||"sortLast"===a?-1:"sortLast"===o||"sortFirst"===a?1:a>o?-1:o>a?1:0}),r?this.get():(n.reverse&&s.reverse(),s)):[]},t.fn.sorted.defaults={reverse:!1,by:null,randomize:!1},t.fn.sorted.randomize=function(t){var e,i,n=t.length
if(!n)return t
for(;--n;)i=Math.floor(Math.random()*(n+1)),e=t[i],t[i]=t[n],t[n]=e
return t}
var n=0,s=function(e,i){var r=this
t.extend(r,s.options,i,s.settings),r.$container=e,r.$window=t(window),r.unique="shuffle_"+n++,r._fire("loading"),r._init(),r._fire("done")}
s.prototype={_init:function(){var e,i=this,n=t.proxy(i._onResize,i),s=i.throttle?i.throttle(i.throttleTime,n):n,r=i.initialSort?i.initialSort:null
i._setVars(),i._resetCols(),i._addClasses(),i._initItems(),i.$window.on("resize.shuffle."+i.unique,s),e=i.$container.css(["paddingLeft","paddingRight","position","width"]),"static"===e.position&&i.$container.css("position","relative"),i.offset={left:parseInt(e.paddingLeft,10)||0,top:parseInt(e.paddingTop,10)||0},i._setColumns(parseInt(e.width,10)),i.shuffle(i.group,r),i.supported&&setTimeout(function(){i._setTransitions(),i.$container[0].style[i.transitionName]="height "+i.speed+"ms "+i.easing},0)},_addClasses:function(){var t=this
return t.$container.addClass("shuffle"),t.$items.addClass("shuffle-item filtered"),t},_setVars:function(){var e=this
return e.$items=e._getItems(),e.transitionName=e.prefixed("transition"),e.transitionDelayName=e.prefixed("transitionDelay"),e.transitionDuration=e.prefixed("transitionDuration"),e.transform=e.getPrefixed("transform"),e.transitionend={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"MSTransitionEnd",transition:"transitionend"}[e.transitionName],e.isFluid=e.columnWidth&&"function"==typeof e.columnWidth,0===e.columnWidth&&null!==e.sizer&&(e.columnWidth=e.sizer),"string"==typeof e.columnWidth?e.$sizer=e.$container.find(e.columnWidth):e.columnWidth&&e.columnWidth.nodeType&&1===e.columnWidth.nodeType?e.$sizer=t(e.columnWidth):e.columnWidth&&e.columnWidth.jquery&&(e.$sizer=e.columnWidth),e.$sizer&&e.$sizer.length&&(e.useSizer=!0,e.sizer=e.$sizer[0]),e},_filter:function(e,n){var s=this,r=n!==i,o=r?n:s.$items,a=t()
return e=e||s.lastFilter,s._fire("filter"),t.isFunction(e)?o.each(function(){var i=t(this),n=e.call(i[0],i,s)
n&&(a=a.add(i))}):(s.group=e,"all"!==e?o.each(function(){var i=t(this),n=i.data("groups"),r=s.delimeter&&!t.isArray(n)?n.split(s.delimeter):n,o=t.inArray(e,r)>-1
o&&(a=a.add(i))}):a=o),s._toggleFilterClasses(o,a),o=null,n=null,a},_toggleFilterClasses:function(e,i){var n="concealed",s="filtered"
e.filter(i).each(function(){var e=t(this)
e.hasClass(n)&&e.removeClass(n),e.hasClass(s)||e.addClass(s)}),e.not(i).each(function(){var e=t(this)
e.hasClass(n)||e.addClass(n),e.hasClass(s)&&e.removeClass(s)})},_initItems:function(t){return t=t||this.$items,t.css(this.itemCss)},_updateItemCount:function(){return this.visibleItems=this.$items.filter(".filtered").length,this},_setTransition:function(t){var e=this
return t.style[e.transitionName]=e.transform+" "+e.speed+"ms "+e.easing+", opacity "+e.speed+"ms "+e.easing,t},_setTransitions:function(t){var e=this
return t=t||e.$items,t.each(function(){e._setTransition(this)}),e},_setSequentialDelay:function(e){var i=this
i.supported&&t.each(e,function(e){this.style[i.transitionDelayName]="0ms,"+(e+1)*i.sequentialFadeDelay+"ms",t(this).one(i.transitionend,function(){this.style[i.transitionDelayName]="0ms"})})},_getItems:function(){return this.$container.children(this.itemSelector)},_getPreciseDimension:function(e,i){var n
return n=window.getComputedStyle?window.getComputedStyle(e,null)[i]:t(e).css(i),parseFloat(n)},_setColumns:function(t){var e,i=this,n=t||i.$container.width(),s="function"==typeof i.gutterWidth?i.gutterWidth(n):i.useSizer?i._getPreciseDimension(i.sizer,"marginLeft"):i.gutterWidth
i.colWidth=i.isFluid?i.columnWidth(n):i.useSizer?i._getPreciseDimension(i.sizer,"width"):i.columnWidth||i.$items.outerWidth(!0)||n,i.colWidth=i.colWidth||n,i.colWidth+=s,e=(n+s)/i.colWidth,Math.ceil(e)-e<.01&&(e=Math.ceil(e)),i.cols=Math.floor(e),i.cols=Math.max(i.cols,1),i.containerWidth=n},_setContainerSize:function(){var t=this,e=Math.max.apply(Math,t.colYs)
t.$container.css("height",e+"px")},_fire:function(t,e){this.$container.trigger(t+".shuffle",e&&e.length?e:[this])},_layout:function(e,i,n,s){var r=this
i=i||r.filterEnd,r.layoutTransitionEnded=!1,t.each(e,function(o){var a=t(e[o]),l=Math.ceil(a.outerWidth(!0)/r.colWidth)
if(l=Math.min(l,r.cols),1===l)r._placeItem(a,r.colYs,i,n,s)
else{var u,d,c=r.cols+1-l,f=[]
for(d=0;c>d;d++)u=r.colYs.slice(d,d+l),f[d]=Math.max.apply(Math,u)
r._placeItem(a,f,i,n,s)}}),r._processStyleQueue(),r._setContainerSize()},_resetCols:function(){var t=this.cols
for(this.colYs=[];t--;)this.colYs.push(0)},_reLayout:function(t,e){var i=this
t=t||i.filterEnd,i._resetCols(),i.keepSorted&&i.lastSort?i.sort(i.lastSort,!0,e):i._layout(i.$items.filter(".filtered").get(),i.filterEnd,e)},_placeItem:function(t,e,i,n,s){for(var r=this,o=Math.min.apply(Math,e),a=0,l=0,u=e.length;u>l;l++)if(e[l]>=o-r.buffer&&e[l]<=o+r.buffer){a=l
break}var d=r.colWidth*a,c=o
d=Math.round(d+r.offset.left),c=Math.round(c+r.offset.top),t.data({x:d,y:c})
var f=o+t.outerHeight(!0),h=r.cols+1-u
for(l=0;h>l;l++)r.colYs[a+l]=f
var p={from:"layout",$this:t,x:d,y:c,scale:1}
n?p.skipTransition=!0:(p.opacity=1,p.callback=i),s&&(p.opacity=0),r.styleQueue.push(p)},_shrink:function(e,i){var n=this,s=e||n.$items.filter(".concealed"),r={},o=i||n.shrinkEnd
s.length&&(n._fire("shrink"),n.shrinkTransitionEnded=!1,s.each(function(){var e=t(this),i=e.data()
r={from:"shrink",$this:e,x:i.x,y:i.y,scale:.001,opacity:0,callback:o},n.styleQueue.push(r)}))},_onResize:function(){var t,e=this
e.enabled&&!e.destroyed&&(t=e.$container.width(),t!==e.containerWidth&&e.resized())},setPrefixedCss:function(t,e,i){t.css(this.prefixed(e),i)},getPrefixed:function(t){var e=this.prefixed(t)
return e?e.replace(/([A-Z])/g,function(t,e){return"-"+e.toLowerCase()}).replace(/^ms-/,"-ms-"):e},transition:function(e){var n,s=this,r=function(){s.layoutTransitionEnded||"layout"!==e.from?s.shrinkTransitionEnded||"shrink"!==e.from||(e.callback.call(s),s.shrinkTransitionEnded=!0):(s._fire("layout"),e.callback.call(s),s.layoutTransitionEnded=!0)}
if(e.callback=e.callback||t.noop,s.supported)e.scale===i&&(e.scale=1),n=s.threeD?"translate3d("+e.x+"px, "+e.y+"px, 0) scale3d("+e.scale+", "+e.scale+", 1)":"translate("+e.x+"px, "+e.y+"px) scale("+e.scale+", "+e.scale+")",e.x!==i&&s.setPrefixedCss(e.$this,"transform",n),e.opacity!==i&&e.$this.css("opacity",e.opacity),e.$this.one(s.transitionend,r)
else{var o={left:e.x,top:e.y,opacity:e.opacity}
e.$this.stop(!0).animate(o,s.speed,"swing",r)}},_processStyleQueue:function(){var e=this,i=e.styleQueue
t.each(i,function(t,i){i.skipTransition?e._skipTransition(i.$this[0],function(){e.transition(i)}):e.transition(i)}),e.styleQueue.length=0},shrinkEnd:function(){this._fire("shrunk")},filterEnd:function(){this._fire("filtered")},sortEnd:function(){this._fire("sorted")},_skipTransition:function(e,i,n){var s,r=this,o=r.transitionDuration,a=e.style[o]
e.style[o]="0ms",t.isFunction(i)?i():e.style[i]=n,s=e.offsetWidth,e.style[o]=a},_addItems:function(t,e,n){var s,r,o=this
o.supported||(e=!1),t.addClass("shuffle-item"),o._initItems(t),o._setTransitions(t),o.$items=o._getItems(),t.css("opacity",0),s=o._filter(i,t),r=s.get(),o._updateItemCount(),e?(o._layout(r,null,!0,!0),n&&o._setSequentialDelay(s),o._revealAppended(s)):o._layout(r)},_revealAppended:function(e){var i=this
setTimeout(function(){e.each(function(e,n){i.transition({from:"reveal",$this:t(n),opacity:1})})},i.revealAppendedDelay)},shuffle:function(t,e){var i=this
i.enabled&&(t||(t="all"),i._filter(t),i.lastFilter=t,i._updateItemCount(),i._resetCols(),i._shrink(),e&&(i.lastSort=e),i._reLayout())},sort:function(t,e,i){var n=this,s=n.$items.filter(".filtered").sorted(t)
e||n._resetCols(),n._layout(s,function(){e&&n.filterEnd(),n.sortEnd()},i),n.lastSort=t},resized:function(t){this.enabled&&(t||this._setColumns(),this._reLayout())},layout:function(){this.update(!0)},update:function(t){this.resized(t)},appended:function(t,e,i){e=e===!1?!1:!0,i=i===!1?!1:!0,this._addItems(t,e,i)},disable:function(){this.enabled=!1},enable:function(t){this.enabled=!0,t!==!1&&this.update()},remove:function(t){if(t.length&&t.jquery){var e=this
return e._shrink(t,function(){var e=this
t.remove(),setTimeout(function(){e.$items=e._getItems(),e.layout(),e._updateItemCount(),e._fire("removed",[t,e]),t=null},0)}),e._processStyleQueue(),e}},destroy:function(){var t=this
t.$window.off("."+t.unique),t.$container.removeClass("shuffle").removeAttr("style").removeData("shuffle"),t.$items.removeAttr("style").removeClass("concealed filtered shuffle-item"),t.destroyed=!0}},s.options={group:"all",speed:250,easing:"ease-out",itemSelector:"",sizer:null,gutterWidth:0,columnWidth:0,delimeter:null,buffer:0,initialSort:null,throttle:t.throttle||null,throttleTime:300,sequentialFadeDelay:150,supported:e.csstransforms&&e.csstransitions},s.settings={$sizer:null,useSizer:!1,itemCss:{position:"absolute",top:0,left:0},offset:{top:0,left:0},revealAppendedDelay:300,keepSorted:!0,enabled:!0,destroyed:!1,styleQueue:[],prefixed:e.prefixed,threeD:e.csstransforms3d},t.fn.shuffle=function(e){var i=Array.prototype.slice.call(arguments,1)
return this.each(function(){var n=t(this),r=n.data("shuffle")
r||(r=new s(n,e),n.data("shuffle",r)),"string"==typeof e&&r[e]&&r[e].apply(r,i)})}}(jQuery,Modernizr)

@ -6,10 +6,14 @@ var DEMO = (function( $ ) {
$sizer = $grid.find('.shuffle__sizer'),
init = function() {
listen();
setupFilters();
setupSorting();
setupSearching();
// None of these need to be executed synchronously
setTimeout(function() {
listen();
setupFilters();
setupSorting();
setupSearching();
}, 100);
// instantiate the plugin
$grid.shuffle({
@ -95,25 +99,33 @@ var DEMO = (function( $ ) {
});
},
// Re layout shuffle when images load. This is only needed
// below 768 pixels because the .picture-item height is auto and therefore
// the height of the picture-item is dependent on the image
// I recommend using imagesloaded to determine when an image is loaded
// but that doesn't support IE7
listen = function() {
var debouncedLayout = $.throttle( 100, function() {
$grid.shuffle('layout');
var debouncedLayout = $.throttle( 300, function() {
$grid.shuffle('update');
});
// Re layout shuffle when images load. This is only needed
// below 768 pixels because the .picture-item height is auto and therefore
// the height of the picture-item is dependent on the image
// I recommend using imagesloaded to determine when an image is loaded
// but that doesn't support IE7
// Get all images inside shuffle
$grid.find('img').each(function() {
var $img = $( this );
var proxyImage;
// Image already loaded
if ( this.complete && this.naturalWidth > 0 ) {
if ( this.complete && this.naturalWidth !== undefined ) {
return;
}
$img.on('load', debouncedLayout);
// If none of the checks above matched, simulate loading on detached element.
proxyImage = new Image();
$( proxyImage ).on('load', function() {
$(this).off('load');
debouncedLayout();
});
proxyImage.src = this.src;
});
};

Loading…
Cancel
Save