Comparing version
/*! | ||
* Muuri v0.5.0 | ||
* Muuri v0.5.1 | ||
* https://github.com/haltu/muuri | ||
@@ -25,6 +25,6 @@ * Copyright (c) 2015, Haltu Oy | ||
/*! | ||
* muuriLayout v0.5.0 | ||
* muuriLayout v0.5.1 | ||
* Copyright (c) 2016 Niklas Rämö <inramo@gmail.com> | ||
* Released under the MIT license | ||
*/ | ||
!function(t,e){var i;if("object"==typeof module&&module.exports){try{i=require("hammerjs")}catch(t){}module.exports=e("Muuri",i)}else"function"==typeof define&&define.amd?define(["hammerjs"],function(t){return e("Muuri",t)}):t.Muuri=e("Muuri",t.Hammer)}("undefined"!=typeof window?window:this,function(t,e,i){"use strict";function n(t,e){var i,r,o,s=this;if(ot||(ot=document.body,It=G()),t=s._element=typeof t===at?nt.querySelector(t):t,!ot.contains(t))throw new et("Container element must be an existing DOM element");typeof(i=s._settings=W(n.defaultOptions,e)).dragSort!==st&&(i.dragSort=!!i.dragSort),mt[s._id=++Dt]=s,s._isDestroyed=!1,s._layout=null,s._emitter=new n.Emitter,s._itemShowHandler=F("show",i),s._itemHideHandler=F("hide",i),A(t,i.containerClass),s._items=[],typeof(r=i.items)===at?H(s._element.children).forEach(function(t){("*"===r||wt(t,r))&&s._items.push(new n.Item(s,t))}):(K.isArray(r)||p(r))&&(s._items=H(r).map(function(t){return new n.Item(s,t)})),(o=!0===(o=i.layoutOnResize)?0:typeof o===lt?o:-1)>=0&&$.addEventListener("resize",s._resizeHandler=y(function(){s.refreshItems().layout()},o)),i.layoutOnInit&&s.layout(!0)}function r(t,e){var i,r=this,o=t._settings;r._id=++Dt,yt[r._id]=r,r._isDestroyed=!1,e.parentNode!==t._element&&t._element.appendChild(e),A(e,o.itemClass),A(e,(i="none"===D(e,"display"))?o.itemHiddenClass:o.itemVisibleClass),r._gridId=t._id,r._element=e,r._child=e.children[0],r._animate=new n.ItemAnimate(r,e),r._animateChild=new n.ItemAnimate(r,r._child),r._isActive=!i,r._isPositioning=!1,r._isHidden=i,r._isHiding=!1,r._isShowing=!1,r._visibilityQueue=[],r._layoutQueue=[],r._left=0,r._top=0,C(e,{left:"0",top:"0",transform:I(0,0),display:i?"none":"block"}),r._refreshDimensions()._refreshSortData(),i?t._itemHideHandler.start(r,!0):t._itemShowHandler.start(r,!0),r._migrate=new n.ItemMigrate(r),r._release=new n.ItemRelease(r),r._drag=o.dragEnabled?new n.ItemDrag(r):null}function o(){this._events={},this._isDestroyed=!1}function s(t,e){var i=this;i._item=t,i._element=e,i._animation=null,i._propsTo=null,i._isDestroyed=!1}function a(t){var e=this;e._itemId=t._id,e._isDestroyed=!1,e.isActive=!1,e.container=!1,e.containerDiffX=0,e.containerDiffY=0}function l(t){var e=this;e._itemId=t._id,e._isDestroyed=!1,e.isActive=!1,e.isPositioningStarted=!1,e.containerDiffX=0,e.containerDiffY=0}function d(i){if(!e)throw new et("["+t+"] required dependency Hammer is not defined.");var n,r,o=this,s=i._element,a=i.getGrid(),l=a._settings,f=typeof l.dragStartPredicate===st?l.dragStartPredicate:d.defaultStartPredicate,u=ct;o._itemId=i._id,o._gridId=a._id,o._hammer=n=new e.Manager(s),o._isDestroyed=!1,o._isMigrating=!1,o._data={},o._resolveStartPredicate=function(t){o._isDestroyed||u!==_t||(u=pt,o.onStart(t))},o._scrollListener=function(t){o.onScroll(t)},o._checkSortOverlap=y(function(){o._data.isActive&&o.checkOverlap()},l.dragSortInterval),o._sortPredicate=typeof l.dragSortPredicate===st?l.dragSortPredicate:d.defaultSortPredicate,o.reset(),n.add(new e.Pan({event:"drag",pointers:1,threshold:0,direction:e.DIRECTION_ALL})),n.add(new e.Press({event:"draginit",pointers:1,threshold:1e3,time:0})),_(l.dragHammerSettings)&&n.set(l.dragHammerSettings),n.on("draginit dragstart dragmove",function(t){u===ct&&(u=_t),u===_t?!0===(r=f(o.getItem(),t))?(u=pt,o.onStart(t)):!1===r&&(u=gt):u===pt&&o._data.isActive&&o.onMove(t)}).on("dragend dragcancel draginitup",function(t){var e=u===pt;f(o.getItem(),t),u=ct,e&&o._data.isActive&&o.onEnd(t)}),s.addEventListener("dragstart",j,!1)}function f(t,e,i){var n=t.length,r=tt.max(0,i?n:n-1);return e>r?r:e<0?tt.max(r+e+1,0):e}function u(t,e,i){if(!(t.length<2)){var n,r=f(t,e),o=f(t,i);r!==o&&(n=t[r],t[r]=t[o],t[o]=n)}}function h(t,e,i){if(!(t.length<2)){var n=f(t,e),r=f(t,i);n!==r&&t.splice(r,0,t.splice(n,1)[0])}}function c(t){var e,i=[],n=t.length;if(n)for(i[0]=t[0],e=1;e<n;e++)i.indexOf(t[e])<0&&i.push(t[e]);return i}function _(t){return"object"==typeof t&&"[object Object]"===J.prototype.toString.call(t)}function p(t){var e=J.prototype.toString.call(t);return"[object HTMLCollection]"===e||"[object NodeList]"===e}function g(t,e){return J.keys(e).forEach(function(i){var n=_(e[i]);_(t[i])&&n?(t[i]=g({},t[i]),t[i]=g(t[i],e[i])):t[i]=n?g({},e[i]):K.isArray(e[i])?e[i].concat():e[i]}),t}function m(t,e,i){var n=typeof i===lt?i:-1;t.splice.apply(t,[n<0?t.length-n+1:n,0].concat(e))}function y(t,e){var n;return e>0?function(r){n!==i&&(n=$.clearTimeout(n),"finish"===r&&t()),"cancel"!==r&&"finish"!==r&&(n=$.setTimeout(function(){n=i,t()},e))}:function(e){"cancel"!==e&&t()}}function v(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function D(t,e){return $.getComputedStyle(t,null).getPropertyValue("transform"===e?St.styleName||e:e)}function w(t,e){return parseFloat(D(t,e))||0}function S(t,e){return parseFloat((D(t,"transform")||"").replace("matrix(","").split(",")["x"===e?4:5])||0}function I(t,e){return"translateX("+t+"px) translateY("+e+"px)"}function b(t,e){var i,n={},r=J.keys(e);for(i=0;i<r.length;i++)n[r[i]]=D(t,v(r[i]));return n}function C(t,e){var i,n=J.keys(e);for(i=0;i<n.length;i++)t.style["transform"===n[i]&&St?St.propName:n[i]]=e[n[i]]}function A(t,e){t.classList?t.classList.add(e):wt(t,"."+e)||(t.className+=" "+e)}function x(t,e){t.classList?t.classList.remove(e):wt(t,"."+e)&&(t.className=(" "+t.className+" ").replace(" "+e+" "," ").trim())}function H(t){return[].slice.call(t)}function E(t,e,i){if(t===e)return{left:0,top:0};i&&(t=L(t,!0),e=L(e,!0));var n=R(t,!0),r=R(e,!0);return{left:r.left-n.left,top:r.top-n.top}}function R(t,e){var i,n={left:0,top:0};return t===nt?n:(n.left=$.pageXOffset||0,n.top=$.pageYOffset||0,t.self===$.self?n:(i=t.getBoundingClientRect(),n.left+=i.left,n.top+=i.top,e&&(n.left+=w(t,"border-left-width"),n.top+=w(t,"border-top-width")),n))}function L(t,e){for(var i=(e?t:t.parentElement)||nt;i&&i!==nt&&"static"===D(i,"position")&&!X(i);)i=i.parentElement||nt;return i}function P(t){var e=[],i=/(auto|scroll)/,n=t.parentNode;if(It){if("fixed"===D(t,"position"))return e;for(;n&&n!==nt&&n!==rt;)i.test(D(n,"overflow")+D(n,"overflow-y")+D(n,"overflow-x"))&&e.push(n),n="fixed"===D(n,"position")?null:n.parentNode;null!==n&&e.push($)}else{for(;n&&n!==nt;)"fixed"!==D(t,"position")||X(n)?(i.test(D(n,"overflow")+D(n,"overflow-y")+D(n,"overflow-x"))&&e.push(n),t=n,n=n.parentNode):n=n.parentNode;e[e.length-1]===rt?e[e.length-1]=$:e.push($)}return e}function G(){if(!St)return!0;var t=[0,1].map(function(t,e){return t=nt.createElement("div"),C(t,{position:e?"fixed":"absolute",display:"block",visibility:"hidden",left:e?"0px":"1px",transform:"none"}),t}),e=ot.appendChild(t[0]),i=e.appendChild(t[1]),n=i.getBoundingClientRect().left;C(e,{transform:"scale(1)"});var r=n===i.getBoundingClientRect().left;return ot.removeChild(e),r}function X(t){var e=D(t,"transform"),i=D(t,"display");return"none"!==e&&"inline"!==i&&"none"!==i}function Y(t,e){return Z.doRectsOverlap(t,e)?(tt.min(t.left+t.width,e.left+e.width)-tt.max(t.left,e.left))*(tt.min(t.top+t.height,e.top+e.height)-tt.max(t.top,e.top))/(tt.min(t.width,e.width)*tt.min(t.height,e.height))*100:0}function O(t){var e,i={};for(e=0;e<t.length;e++)i[t[e]._id]=e;return i}function k(t,e,i,n){var r=n[t._id],o=n[e._id];return i?o-r:r-o}function M(t,e,i,n){var r,o,s,a,l,d=0;for(l=0;l<n.length;l++)if(r=n[l][0],o=n[l][1],s=(t._sortData?t:t._refreshSortData())._sortData[r],a=(e._sortData?e:e._refreshSortData())._sortData[r],0!==(d="desc"===o||!o&&i?a<s?-1:a>s?1:0:s<a?-1:s>a?1:0))return d;return d}function N(t,e){var i,n,r,o=[],s=t.concat();for(r=0;r<e.length;r++)i=e[r],(n=s.indexOf(i))>-1&&(o.push(i),s.splice(n,1));return t.splice.apply(t,[0,t.length].concat(o).concat(s)),t}function T(t,e,i){return i.width&&i.height&&t>=i.left&&t<i.left+i.width&&e>=i.top&&e<i.top+i.height}function z(t,e,n,r){var o,s,a=t.getItems(n),l=r||{},d=!0===l.instant,f=l.onFinish,u=l.layout?l.layout:l.layout===i,h=a.length,c="show"===e,_=c?Ct:xt,p=c?At:Ht,g=!1,m=[],y=[];if(h){for(t._emit(_,a.concat()),s=0;s<a.length;s++)o=a[s],(c&&!o._isActive||!c&&o._isActive)&&(g=!0),c&&!o._isActive&&(o._skipNextLayoutAnimation=!0),c&&o._isHidden&&y.push(o),o["_"+e](d,function(e,i){e||m.push(i),--h<1&&(typeof f===st&&f(m.concat()),t._emit(p,m.concat()))});y.length&&t.refreshItems(y),g&&u&&t.layout("instant"===u,typeof u===st?u:i)}else typeof f===st&&f(a);return t}function F(t,e){var i,n="show"===t,r=parseInt(n?e.showDuration:e.hideDuration)||0,o=(n?e.showEasing:e.hideEasing)||"ease",s=n?e.visibleStyles:e.hiddenStyles,a=r>0;return s=_(s)?s:null,{start:function(t,e,n){s?(dt.cancel(ft,t._id),!a||e?(t._animateChild.isAnimating()?t._animateChild.stop(s):C(t._child,s),n&&n()):dt.add(ft,t._id,function(){i=b(t._child,s)},function(){t._animateChild.start(i,s,{duration:r,easing:o,onFinish:n})})):n&&n()},stop:function(t,e){dt.cancel(ft,t._id),t._animateChild.stop(e)}}}function B(t,e,i,n){var r,o,s,a=null,l=e._settings.dragSort,d=!0===l?[e]:l.call(e,t),f=-1;if(!K.isArray(d))return a;for(s=0;s<d.length;s++)(o=d[s])._isDestroyed||(o._refreshDimensions(),(r=Y(i,{width:o._width,height:o._height,left:o._left,top:o._top}))>n&&r>f&&(f=r,a=o));return a}function V(t,e,i){var n,r=t.splice(0,t.length);for(n=0;n<r.length;n++)r[n](e,i)}function Q(t,e){var i;return"inactive"===e?!t.isActive():"hidden"===e?!t.isVisible():(i="is"+e.charAt(0).toUpperCase()+e.slice(1),typeof t[i]===st&&t[i]())}function j(t){t.preventDefault&&t.preventDefault()}function W(t,e){var i=g({},t);return i=e?g(i,e):i,i.visibleStyles=(e||{}).visibleStyles||(t||{}).visibleStyles,i.hiddenStyles=(e||{}).hiddenStyles||(t||{}).hiddenStyles,i}function q(t,e){var i,n=t._drag._startPredicateData;if(!(e.distance<n.distance||n.delay))return i=n.handleElement.getBoundingClientRect(),U(t),T(e.srcEvent.pageX,e.srcEvent.pageY,{width:i.width,height:i.height,left:i.left+($.pageXOffset||0),top:i.top+($.pageYOffset||0)})}function U(t){var e=t._drag._startPredicateData;e&&(e.delayTimer&&(e.delayTimer=$.clearTimeout(e.delayTimer)),t._drag._startPredicateData=null)}function Z(t,e,i,n){var r,o,s,a,l,d,f,u=!!n.fillGaps,h=!!n.horizontal,c=!!n.alignRight,_=!!n.alignBottom,p=!!n.rounding,g={slots:{},width:h?0:p?tt.round(e):e,height:h?p?tt.round(i):i:0,setWidth:h,setHeight:!h},m=[];if(!t.length)return g;for(f=0;f<t.length;f++)l=(a=t[f])._width+a._margin.left+a._margin.right,d=a._height+a._margin.top+a._margin.bottom,p&&(l=tt.round(l),d=tt.round(d)),s=(o=Z.getSlot(g,m,l,d,!h,u))[0],m=o[1],h?g.width=tt.max(g.width,s.left+s.width):g.height=tt.max(g.height,s.top+s.height),g.slots[a._id]=s;if(c||_)for(r=J.keys(g.slots),f=0;f<r.length;f++)s=g.slots[r[f]],c&&(s.left=g.width-(s.left+s.width)),_&&(s.top=g.height-(s.top+s.height));return g}var $=window,J=$.Object,K=$.Array,tt=$.Math,et=$.Error,it=$.Element,nt=$.document,rt=nt.documentElement,ot=nt.body,st="function",at="string",lt="number",dt=function(){function t(){var a,l=+n._maxRafBatchSize||100,d=r.splice(0,tt.min(l,r.length));for(e=null,a=0;a<d.length;a++)o[d[a]][0]();for(a=0;a<d.length;a++)o[d[a]][1](),o[d[a]]=i;!e&&r.length&&(e=s(t))}var e=null,r=[],o={},s=($.requestAnimationFrame||$.webkitRequestAnimationFrame||$.mozRequestAnimationFrame||$.msRequestAnimationFrame||function(t){return $.setTimeout(t,16)}).bind($);return{add:function(i,n,a,l){var d=r.indexOf(i+n);d>-1&&r.splice(d,1),i===ut||i===ht?r.unshift(i+n):r.push(i+n),o[i+n]=[a,l],!e&&(e=s(t))},cancel:function(t,e){var n=r.indexOf(t+e);n>-1&&(r.splice(n,1),o[t+e]=i)}}}(),ft="visibility",ut="move",ht="scroll",ct=0,_t=1,pt=2,gt=3,mt={},yt={},vt=function(){},Dt=0,wt=function(){var t=it.prototype,e=t.matches||t.matchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector;return function(t,i){return e.call(t,i)}}(),St=function(t){var e,n,r,o=t.charAt(0).toUpperCase()+t.slice(1),s=["","Webkit","Moz","O","ms"];for(r=0;r<s.length;r++)if(e=s[r],n=e?e+o:t,rt.style[n]!==i)return e=e.toLowerCase(),{prefix:e,propName:n,styleName:e?"-"+e+"-"+t:t};return null}("transform"),It=ot?G():null,bt="layoutEnd",Ct="showStart",At="showEnd",xt="hideStart",Ht="hideEnd";return n.Item=r,n.ItemDrag=d,n.ItemRelease=l,n.ItemMigrate=a,n.ItemAnimate=s,n.Layout=function(t,e){var i=this,n=t._settings.layout;e=e.concat(),t._refreshDimensions();var r=t._width-t._border.left-t._border.right,o=t._height-t._border.top-t._border.bottom,s=typeof n===st?n(e,r,o):Z(e,r,o,_(n)?n:{});i.slots=s.slots,i.setWidth=s.setWidth||!1,i.setHeight=s.setHeight||!1,i.width=s.width,i.height=s.height},n.Emitter=o,n.defaultOptions={items:"*",showDuration:300,showEasing:"ease",hideDuration:300,hideEasing:"ease",visibleStyles:{opacity:"1",transform:"scale(1)"},hiddenStyles:{opacity:"0",transform:"scale(0.5)"},layout:{fillGaps:!1,horizontal:!1,alignRight:!1,alignBottom:!1,rounding:!0},layoutOnResize:100,layoutOnInit:!0,layoutDuration:300,layoutEasing:"ease",sortData:null,dragEnabled:!1,dragContainer:null,dragStartPredicate:{distance:0,delay:0,handle:!1},dragAxis:null,dragSort:!0,dragSortInterval:100,dragSortPredicate:{threshold:50,action:"move"},dragReleaseDuration:300,dragReleaseEasing:"ease",dragHammerSettings:{touchAction:"none"},containerClass:"muuri",itemClass:"muuri-item",itemVisibleClass:"muuri-item-shown",itemHiddenClass:"muuri-item-hidden",itemPositioningClass:"muuri-item-positioning",itemDraggingClass:"muuri-item-dragging",itemReleasingClass:"muuri-item-releasing"},n._maxRafBatchSize=100,n.prototype.on=function(t,e){var i=this;return i._isDestroyed||i._emitter.on(t,e),i},n.prototype.once=function(t,e){var i=this;return i._isDestroyed||i._emitter.once(t,e),i},n.prototype.off=function(t,e){var i=this;return i._isDestroyed||i._emitter.off(t,e),i},n.prototype.getElement=function(){return this._element},n.prototype.getItems=function(t,e){var i=this;if(i._isDestroyed)return[];var n,r,o=0===t||t&&typeof t!==at,s=o?p(t)?H(t):[].concat(t):null,a=o?e:t,l=[];if((a=typeof a===at?a:null)||s){for(s=s||i._items,r=0;r<s.length;r++)!(n=o?i._getItem(s[r]):s[r])||a&&!Q(n,a)||l.push(n);return l}return l.concat(i._items)},n.prototype.refreshItems=function(t){var e=this;if(e._isDestroyed)return e;var i,n=e.getItems(t||"active");for(i=0;i<n.length;i++)n[i]._refreshDimensions();return e},n.prototype.refreshSortData=function(t){var e=this;if(e._isDestroyed)return e;var i,n=e.getItems(t);for(i=0;i<n.length;i++)n[i]._refreshSortData();return e},n.prototype.synchronize=function(){var t=this;if(t._isDestroyed)return t;var e,i,n,r=t._element,o=t._items;if(o.length){for(n=0;n<o.length;n++)(i=o[n]._element).parentNode===r&&(e=e||nt.createDocumentFragment()).appendChild(i);e&&r.appendChild(e)}return t._emit("synchronize"),t},n.prototype.layout=function(t,e){function i(){--_<=0&&(typeof f===st&&f(r._layout!==c,h.concat()),r._layout===c&&r._emit(bt,h.concat()))}var r=this;if(r._isDestroyed)return r;var o,s,a,l,d,f=typeof t===st?t:e,u=!0===t,h=r.getItems("active"),c=r._layout=new n.Layout(r,h),_=h.length;if((c.setWidth||c.setHeight)&&(s={},o="border-box"===D(r._element,"box-sizing"),c.setHeight&&(typeof c.height===lt?s.height=(o?c.height+r._border.top+r._border.bottom:c.height)+"px":s.height=c.height),c.setWidth&&(typeof c.width===lt?s.width=(o?c.width+r._border.left+r._border.right:c.width)+"px":s.width=c.width),C(r._element,s)),r._emit("layoutStart",h.concat()),!h.length)return i(),r;for(d=0;d<h.length;d++)a=h[d],l=c.slots[a._id],a._left=l.left,a._top=l.top,a.isDragging()?i():a._layout(u,i);return r},n.prototype.add=function(t,e){var r=this;if(r._isDestroyed)return[];var o=[].concat(t),s=[];if(!o.length)return s;var a,l,d,f=e||{},u=f.layout?f.layout:f.layout===i,h=r._items,c=!1;for(d=0;d<h.length;d++)if((a=o.indexOf(h[d]._element))>-1&&(o.splice(a,1),!o.length))return s;for(d=0;d<o.length;d++)l=new n.Item(r,o[d]),s.push(l),l._isActive&&(c=!0,l._skipNextLayoutAnimation=!0);return m(h,s,f.index),r._emit("add",s.concat()),c&&u&&r.layout("instant"===u,typeof u===st?u:i),s},n.prototype.remove=function(t,e){var n=this;if(n._isDestroyed)return n;var r,o,s=e||{},a=s.layout?s.layout:s.layout===i,l=!1,d=n.getItems(t);for(o=0;o<d.length;o++)(r=d[o])._isActive&&(l=!0),r._destroy(s.removeElements);return n._emit("remove",d.concat()),l&&a&&n.layout("instant"===a,typeof a===st?a:i),d},n.prototype.show=function(t,e){return this._isDestroyed?this:z(this,"show",t,e)},n.prototype.hide=function(t,e){return this._isDestroyed?this:z(this,"hide",t,e)},n.prototype.filter=function(t,e){var n=this;if(n._isDestroyed||!n._items.length)return n;var r,o,s=n._items,a=typeof t,l=a===at,d=a===st,f=e||{},u=!0===f.instant,h=f.layout?f.layout:f.layout===i,c=typeof f.onFinish===st?f.onFinish:null,_=[],p=[],g=-1,m=c?function(){++g&&c(_.concat(),p.concat())}:vt;if(d||l)for(o=0;o<s.length;o++)r=s[o],(d?t(r):wt(r._element,t))?_.push(r):p.push(r);return _.length?n.show(_,{instant:u,onFinish:m,layout:!1}):m(),p.length?n.hide(p,{instant:u,onFinish:m,layout:!1}):m(),(_.length||p.length)&&(n._emit("filter",_.concat(),p.concat()),h&&n.layout("instant"===h,typeof h===st?h:i)),n},n.prototype.sort=function(t,e){var n=this;if(n._isDestroyed||n._items.length<2)return n;var r,o=n._items,s=e||{},a=!!s.descending,l=s.layout?s.layout:s.layout===i,d=o.concat();if(typeof t===st)o.sort(function(e,i){var n=t(e,i);return(a&&0!==n?-n:n)||k(e,i,a,r||(r=O(d)))});else if(typeof t===at)t=t.trim().split(" ").map(function(t){return t.split(":")}),o.sort(function(e,i){return M(e,i,a,t)||k(e,i,a,r||(r=O(d)))});else{if(!K.isArray(t))return n;N(o,t),a&&o.reverse()}return n._emit("sort",o.concat(),d),l&&n.layout("instant"===l,typeof l===st?l:i),n},n.prototype.move=function(t,e,n){var r=this;if(r._isDestroyed||r._items.length<2)return r;var o,s,a=r._items,l=n||{},d=l.layout?l.layout:l.layout===i,f="swap"===l.action,c=f?"swap":"move",_=r._getItem(t),p=r._getItem(e);return _&&p&&_!==p&&(o=a.indexOf(_),s=a.indexOf(p),(f?u:h)(a,o,s),r._emit("move",{item:_,fromIndex:o,toIndex:s,action:c}),d&&r.layout("instant"===d,typeof d===st?d:i)),r},n.prototype.send=function(t,e,n,r){var o=this;if(o._isDestroyed||e._isDestroyed||o===e||!(t=o._getItem(t)))return o;var s=e,a=r||{},l=a.appendTo||ot,d=a.layoutSender?a.layoutSender:a.layoutSender===i,f=a.layoutReceiver?a.layoutReceiver:a.layoutReceiver===i;return t._migrate.start(s,n,l),t._migrate.isActive&&t.isActive()&&(d&&o.layout("instant"===d,typeof d===st?d:i),f&&s.layout("instant"===f,typeof f===st?f:i)),o},n.prototype.destroy=function(t){var e=this;if(e._isDestroyed)return e;var n,r=e._element,o=e._items.concat();for(e._resizeHandler&&$.removeEventListener("resize",e._resizeHandler),n=0;n<o.length;n++)o[n]._destroy(t);return x(r,e._settings.containerClass),C(r,{height:""}),e._emit("destroy"),e._emitter.destroy(),mt[e._id]=i,e._isDestroyed=!0,e},n.prototype._getItem=function(t){var e,i=this,n=i._items;if(i._isDestroyed||!t)return n[0]||null;if(typeof t===lt)return n[t>-1?t:n.length+t]||null;if(t instanceof r)return t._gridId===i._id?t:null;for(e=0;e<n.length;e++)if(n[e]._element===t)return n[e];return null},n.prototype._emit=function(){var t=this;return t._isDestroyed||t._emitter.emit.apply(t._emitter,arguments),t},n.prototype._refreshDimensions=function(){var t,e=this,i=e._element,n=i.getBoundingClientRect(),r=["left","right","top","bottom"];for(e._width=n.width,e._height=n.height,e._left=n.left,e._top=n.top,e._border={},t=0;t<r.length;t++)e._border[r[t]]=w(i,"border-"+r[t]+"-width");return e},r.prototype.getGrid=function(){return mt[this._gridId]},r.prototype.getElement=function(){return this._element},r.prototype.getWidth=function(){return this._width},r.prototype.getHeight=function(){return this._height},r.prototype.getMargin=function(){return{left:this._margin.left,right:this._margin.right,top:this._margin.top,bottom:this._margin.bottom}},r.prototype.getPosition=function(){return{left:this._left,top:this._top}},r.prototype.isActive=function(){return this._isActive},r.prototype.isVisible=function(){return!this._isHidden},r.prototype.isShowing=function(){return this._isShowing},r.prototype.isHiding=function(){return this._isHiding},r.prototype.isPositioning=function(){return this._isPositioning},r.prototype.isDragging=function(){return!!this._drag&&this._drag._data.isActive},r.prototype.isReleasing=function(){return this._release.isActive},r.prototype.isDestroyed=function(){return this._isDestroyed},r.prototype._refreshDimensions=function(){var t=this;if(t._isDestroyed||t._isHidden)return t;var e,i,n=t._element,r=n.getBoundingClientRect(),o=["left","right","top","bottom"],s=t._margin=t._margin||{};for(t._width=r.width,t._height=r.height,i=0;i<4;i++)e=w(n,"margin-"+o[i]),s[o[i]]=e>0?e:0;return t},r.prototype._refreshSortData=function(){var t=this;if(t._isDestroyed)return t;var e={},i=t.getGrid()._settings.sortData;return i&&J.keys(i).forEach(function(n){e[n]=i[n](t,t._element)}),t._sortData=e,t},r.prototype._layout=function(t,e){var i=this;if(i._isDestroyed)return i;var n,r,o,s,a,l,d=i._element,f=i._isPositioning,u=i._migrate,h=i._release,c=h.isActive&&!1===h.isPositioningStarted,_=i.getGrid()._settings,p=c?_.dragReleaseDuration:_.layoutDuration,g=c?_.dragReleaseEasing:_.layoutEasing,m=!t&&!i._skipNextLayoutAnimation&&p>0;return f&&V(i._layoutQueue,!0,i),c&&(h.isPositioningStarted=!0),typeof e===st&&i._layoutQueue.push(e),r=h.isActive?h.containerDiffX:u.isActive?u.containerDiffX:0,o=h.isActive?h.containerDiffY:u.isActive?u.containerDiffY:0,l={transform:I(i._left+r,i._top+o)},m?(i._isPositioning=!0,dt.add("layout",i._id,function(){s=S(d,"x")-r,a=S(d,"y")-o},function(){if(i._left===s&&i._top===a)return f&&i._stopLayout(!1,l),i._isPositioning=!1,i._finishLayout();!f&&A(d,_.itemPositioningClass),i._animate.start({transform:I(s+r,a+o)},l,{duration:p,easing:g,onFinish:function(){i._finishLayout()}})}),i):(f&&dt.cancel("layout",i._id),n=i._animate.isAnimating(),i._stopLayout(!1,l),!n&&C(d,l),i._skipNextLayoutAnimation=!1,i._finishLayout())},r.prototype._finishLayout=function(){var t=this;return t._isDestroyed?t:(t._isPositioning&&(t._isPositioning=!1,x(t._element,t.getGrid()._settings.itemPositioningClass)),t._release.isActive&&t._release.stop(),t._migrate.isActive&&t._migrate.stop(),V(t._layoutQueue,!1,t),t)},r.prototype._stopLayout=function(t,e){var i=this;return i._isDestroyed||!i._isPositioning?i:(dt.cancel("layout",i._id),i._animate.stop(e),x(i._element,i.getGrid()._settings.itemPositioningClass),i._isPositioning=!1,t&&V(i._layoutQueue,!0,i),i)},r.prototype._show=function(t,e){var i=this;if(i._isDestroyed)return i;var n=i._element,r=i._visibilityQueue,o=typeof e===st?e:null,s=i.getGrid(),a=s._settings;return i._isShowing||i._isHidden?i._isShowing&&!t?(o&&r.push(o),i):(i._isShowing||(V(r,!0,i),x(n,a.itemHiddenClass),A(n,a.itemVisibleClass),!i._isHiding&&C(n,{display:"block"})),o&&r.push(o),i._isActive=i._isShowing=!0,i._isHiding=i._isHidden=!1,t?(s._itemShowHandler.stop(i,a.visibleStyles),i._isShowing=!1,V(r,!1,i)):s._itemShowHandler.start(i,t,function(){i._isHidden||(i._isShowing=!1,V(r,!1,i))}),i):(o&&o(!1,i),i)},r.prototype._hide=function(t,e){var i=this;if(i._isDestroyed)return i;var n=i._element,r=i._visibilityQueue,o=typeof e===st?e:null,s=i.getGrid(),a=s._settings;return!i._isHiding&&i._isHidden?(o&&o(!1,i),i):i._isHiding&&!t?(o&&r.push(o),i):(i._isHiding||(V(r,!0,i),A(n,a.itemHiddenClass),x(n,a.itemVisibleClass)),o&&r.push(o),i._isHidden=i._isHiding=!0,i._isActive=i._isShowing=!1,t?(s._itemHideHandler.stop(i,a.hiddenStyles),i._isHiding=!1,i._stopLayout(!0,{transform:I(0,0)}),C(n,{display:"none"}),V(r,!1,i)):s._itemHideHandler.start(i,t,function(){i._isHidden&&(i._isHiding=!1,i._stopLayout(!0,{transform:I(0,0)}),C(n,{display:"none"}),V(r,!1,i))}),i)},r.prototype._destroy=function(t){var e=this;if(e._isDestroyed)return e;var n=e._element,r=e.getGrid(),o=r._settings,s=r._items.indexOf(e);return e._release.destroy(),e._migrate.destroy(),e._stopLayout(!0,{}),r._itemShowHandler.stop(e,{}),r._itemHideHandler.stop(e,{}),e._drag&&e._drag.destroy(),e._animate.destroy(),e._animateChild.destroy(),V(e._visibilityQueue,!0,e),n.removeAttribute("style"),e._child.removeAttribute("style"),x(n,o.itemPositioningClass),x(n,o.itemDraggingClass),x(n,o.itemReleasingClass),x(n,o.itemClass),x(n,o.itemVisibleClass),x(n,o.itemHiddenClass),s>-1&&r._items.splice(s,1),t&&n.parentNode.removeChild(n),yt[e._id]=i,e._isActive=e._isPositioning=e._isHiding=e._isShowing=!1,e._isDestroyed=e._isHidden=!0,e},o.prototype.on=function(t,e){var i=this;if(i._isDestroyed)return i;var n=i._events[t]||[];return n.push(e),i._events[t]=n,i},o.prototype.once=function(t,e){var i=this;return this.on(t,function n(){i.off(t,n),e.apply(null,arguments)})},o.prototype.off=function(t,e){var i=this;if(i._isDestroyed)return i;for(var n=i._events[t]||[],r=n.length;r--;)e===n[r]&&n.splice(r,1);return i},o.prototype.emit=function(t,e,i,n){var r=this;if(r._isDestroyed)return r;var o,s=r._events[t]||[],a=s.length,l=arguments.length-1;if(a)for(s=s.concat(),o=0;o<a;o++)0===l?s[o]():1===l?s[o](e):2===l?s[o](e,i):s[o](e,i,n);return r},o.prototype.destroy=function(){var t=this;if(t._isDestroyed)return t;var e,i=J.keys(t._events);for(e=0;e<i.length;e++)t._events[i[e]]=null;return t._isDestroyed=!0,t},s.prototype.start=function(t,e,i){var n=this;if(!n._isDestroyed){var r=i||{},o=typeof r.onFinish===st?r.onFinish:null;if(n._animation){if(!J.keys(e).some(function(t){return e[t]!==n._propsTo[t]}))return void(n._animation.onfinish=function(){n._animation=n._propsTo=null,o&&o()});n._animation.cancel()}n._propsTo=e,n._animation=n._element.animate([t,e],{duration:r.duration||300,easing:r.easing||"ease"}),n._animation.onfinish=function(){n._animation=n._propsTo=null,o&&o()},C(n._element,e)}},s.prototype.stop=function(t){var e=this;!e._isDestroyed&&e._animation&&(C(e._element,t||b(e._element,e._propsTo)),e._animation.cancel(),e._animation=e._propsTo=null)},s.prototype.isAnimating=function(){return!!this._animation},s.prototype.destroy=function(){var t=this;t._isDestroyed||(t.stop(),t._item=t._element=null,t._isDestroyed=!0)},a.prototype.destroy=function(){var t=this;return t._isDestroyed||(t.stop(!0),t._isDestroyed=!0),t},a.prototype.getItem=function(){return yt[this._itemId]||null},a.prototype.start=function(t,e,r){var o=this;if(o._isDestroyed)return o;var s,a,l,d,u,h=o.getItem(),c=h._element,_=h.isVisible(),p=h.getGrid(),g=p._settings,y=t._settings,v=t._element,D=p._items.indexOf(h),w=typeof e===lt?e:t._items.indexOf(t._getItem(e)),b=r||ot;return null===w?o:(w=f(t._items,w,!0),(h.isPositioning()||o.isActive||h.isReleasing())&&(d=S(c,"x"),u=S(c,"y")),h.isPositioning()&&h._stopLayout(!0,{transform:I(d,u)}),o.isActive&&(d-=o.containerDiffX,u-=o.containerDiffY,o.stop(!0,{transform:I(d,u)})),h.isReleasing()&&(d-=h._release.containerDiffX,u-=h._release.containerDiffY,h._release.stop(!0,{transform:I(d,u)})),p._itemShowHandler.stop(h),p._itemHideHandler.stop(h),h._drag&&h._drag.destroy(),h._animate.destroy(),h._animateChild.destroy(),V(h._visibilityQueue,!0,h),p._emit("beforeSend",{item:h,fromGrid:p,fromIndex:D,toGrid:t,toIndex:w}),t._emit("beforeReceive",{item:h,fromGrid:p,fromIndex:D,toGrid:t,toIndex:w}),x(c,g.itemClass),x(c,g.itemVisibleClass),x(c,g.itemHiddenClass),A(c,y.itemClass),A(c,_?y.itemVisibleClass:y.itemHiddenClass),p._items.splice(D,1),m(t._items,h,w),h._gridId=t._id,h._animate=new n.ItemAnimate(h,c),h._animateChild=new n.ItemAnimate(h,h._child),s=c.parentNode,b!==s&&(b.appendChild(c),a=E(b,s,!0),d===i&&(d=S(c,"x"),u=S(c,"y")),C(c,{transform:I(d+a.left,u+a.top)})),h._child.removeAttribute("style"),_?t._itemShowHandler.start(h,!0):t._itemHideHandler.start(h,!0),C(c,{display:_?"block":"hidden"}),l=E(b,v,!0),h._refreshDimensions()._refreshSortData(),h._drag=y.dragEnabled?new n.ItemDrag(h):null,o.isActive=!0,o.container=b,o.containerDiffX=l.left,o.containerDiffY=l.top,p._emit("send",{item:h,fromGrid:p,fromIndex:D,toGrid:t,toIndex:w}),t._emit("receive",{item:h,fromGrid:p,fromIndex:D,toGrid:t,toIndex:w}),o)},a.prototype.stop=function(t,e){var i=this;if(i._isDestroyed||!i.isActive)return i;var n=i.getItem(),r=n._element,o=n.getGrid()._element;return i.container!==o&&(e||(e={transform:I(t?S(r,"x")-i.containerDiffX:n._left,t?S(r,"y")-i.containerDiffY:n._top)}),o.appendChild(r),C(r,e)),i.isActive=!1,i.container=null,i.containerDiffX=0,i.containerDiffY=0,i},l.prototype.destroy=function(){var t=this;return t._isDestroyed||(t.stop(!0),t._isDestroyed=!0),t},l.prototype.getItem=function(){return yt[this._itemId]||null},l.prototype.reset=function(){var t=this;if(t._isDestroyed)return t;var e=t.getItem();return t.isActive=!1,t.isPositioningStarted=!1,t.containerDiffX=0,t.containerDiffY=0,x(e._element,e.getGrid()._settings.itemReleasingClass),t},l.prototype.start=function(){var t=this;if(t._isDestroyed||t.isActive)return t;var e=t.getItem(),i=e.getGrid();return t.isActive=!0,A(e._element,i._settings.itemReleasingClass),i._emit("dragReleaseStart",e),e._layout(!1),t},l.prototype.stop=function(t,e){var i=this;if(i._isDestroyed||!i.isActive)return i;var n=i.getItem(),r=n._element,o=n.getGrid(),s=o._element,a=i.containerDiffX,l=i.containerDiffY;return i.reset(),r.parentNode!==s&&(e||(e={transform:I(t?S(r,"x")-a:n._left,t?S(r,"y")-l:n._top)}),s.appendChild(r),C(r,e)),t||o._emit("dragReleaseEnd",n),i},d.defaultStartPredicate=function(t,e,i){var n,r,o,s,a=t._element,l=t._drag._startPredicateData;if(l||(n=_(n=i||t._drag.getGrid()._settings.dragStartPredicate)?n:{},l=t._drag._startPredicateData={distance:tt.abs(n.distance)||0,delay:tt.max(n.delay,0)||0,handle:"string"==typeof n.handle&&n.handle}),e.isFinal)return r="a"===a.tagName.toLowerCase(),o=a.getAttribute("href"),s=a.getAttribute("target"),U(t),void(r&&o&&tt.abs(e.deltaX)<2&&tt.abs(e.deltaY)<2&&e.deltaTime<200&&(s&&"_self"!==s?$.open(o,s):$.location.href=o));if(!l.handleElement)if(l.handle){for(l.handleElement=e.srcEvent.target;l.handleElement&&!wt(l.handleElement,l.handle);)l.handleElement=l.handleElement!==a?l.handleElement.parentElement:null;if(!l.handleElement)return!1}else l.handleElement=a;return l.delay&&(l.event=e,l.delayTimer||(l.delayTimer=$.setTimeout(function(){l.delay=0,q(t,l.event)&&(t._drag._resolveStartPredicate(l.event),U(t))},l.delay))),q(t,e)},d.defaultSortPredicate=function(t){var e,i,n,r,o,s=t._drag,a=s._data,l=s.getGrid(),d=l._settings.dragSortPredicate||{},f=d.threshold||50,u=d.action||"move",h={width:t._width,height:t._height,left:a.elementClientX,top:a.elementClientY},c=B(t,l,h,f),_=0,p=0,g=-1;if(!c)return!1;for(c===l?(h.left=a.gridX+t._margin.left,h.top=a.gridY+t._margin.top):(_=c._left+c._border.left,p=c._top+c._border.top),o=0;o<c._items.length;o++)(n=c._items[o])._isActive&&n!==t&&(i=!0,(r=Y(h,{width:n._width,height:n._height,left:n._left+n._margin.left+_,top:n._top+n._margin.top+p}))>g&&(e=o,g=r));return g<f&&t.getGrid()!==c&&(e=i?-1:0,g=1/0),g>=f&&{grid:c,index:e,action:u}},d.prototype.destroy=function(){var t=this;return t._isDestroyed||(t.stop(),t._hammer.destroy(),t.getItem()._element.removeEventListener("dragstart",j,!1),t._isDestroyed=!0),t},d.prototype.getItem=function(){return yt[this._itemId]||null},d.prototype.getGrid=function(){return mt[this._gridId]||null},d.prototype.reset=function(){var t=this,e=t._data;return e.isActive=!1,e.container=null,e.containingBlock=null,e.startEvent=null,e.currentEvent=null,e.scrollers=[],e.left=0,e.top=0,e.gridX=0,e.gridY=0,e.elementClientX=0,e.elementClientY=0,e.containerDiffX=0,e.containerDiffY=0,t},d.prototype.bindScrollListeners=function(){var t,e=this,i=e.getGrid()._element,n=e._data.container,r=P(e.getItem()._element);for(n!==i&&(r=c(r.concat(i).concat(P(i)))),t=0;t<r.length;t++)r[t].addEventListener("scroll",e._scrollListener);return e._data.scrollers=r,e},d.prototype.unbindScrollListeners=function(){var t,e=this,i=e._data,n=i.scrollers;for(t=0;t<n.length;t++)n[t].removeEventListener("scroll",e._scrollListener);return i.scrollers=[],e},d.prototype.checkOverlap=function(){var t,e,i,n,r,o,s=this,a=s.getItem(),l=s._sortPredicate(a,s._data.currentEvent);return _(l)&&typeof l.index===lt?(t=a.getGrid(),i=l.grid||t,o=t!==i,e=t._items.indexOf(a),n=f(t._items,l.index,o),r="swap"===l.action?"swap":"move",o?(t._emit("beforeSend",{item:a,fromGrid:t,fromIndex:e,toGrid:i,toIndex:n}),i._emit("beforeReceive",{item:a,fromGrid:t,fromIndex:e,toGrid:i,toIndex:n}),a._gridId=i._id,s._isMigrating=a._gridId!==s._gridId,t._items.splice(e,1),m(i._items,a,n),a._sortData=null,t._emit("send",{item:a,fromGrid:t,fromIndex:e,toGrid:i,toIndex:n}),i._emit("receive",{item:a,fromGrid:t,fromIndex:e,toGrid:i,toIndex:n}),t.layout(),i.layout()):e!==n&&(("swap"===r?u:h)(t._items,e,n),t._emit("move",{item:a,fromIndex:e,toIndex:n,action:r}),t.layout()),s):s},d.prototype.finishMigration=function(){var t,e,i,r=this,o=r.getItem(),s=o._release,a=o._element,l=o.getGrid(),d=l._element,f=l._settings,u=f.dragContainer||d,h=r.getGrid()._settings,c=a.parentNode;return r._isMigrating=!1,r.destroy(),o._animate.destroy(),o._animateChild.destroy(),x(a,h.itemClass),x(a,h.itemVisibleClass),x(a,h.itemHiddenClass),A(a,f.itemClass),A(a,f.itemVisibleClass),o._animate=new n.ItemAnimate(o,a),o._animateChild=new n.ItemAnimate(o,o._child),u!==c&&(u.appendChild(a),i=E(c,u,!0),t=S(a,"x")-i.left,e=S(a,"y")-i.top),o._refreshDimensions()._refreshSortData(),i=E(u,d,!0),s.containerDiffX=i.left,s.containerDiffY=i.top,o._drag=f.dragEnabled?new n.ItemDrag(o):null,u!==c&&C(a,{transform:I(t,e)}),o._child.removeAttribute("style"),l._itemShowHandler.start(o,!0),s.start(),r},d.prototype.cancelRafLoop=function(){var t=this.getItem()._id;return dt.cancel(ht,t),dt.cancel(ut,t),this},d.prototype.stop=function(){var t=this,e=t._data,i=t.getItem()._element,n=t.getGrid();return e.isActive?t._isMigrating?t.finishMigration(e.currentEvent):(t.cancelRafLoop(),t.unbindScrollListeners(),t._checkSortOverlap("cancel"),i.parentNode!==n._element&&(n._element.appendChild(i),C(i,{transform:I(e.gridX,e.gridY)})),x(i,n._settings.itemDraggingClass),t.reset(),t):t},d.prototype.onStart=function(t){var e=this,i=e.getItem();if(!i._isActive)return e;var n=i._element,r=e.getGrid(),o=r._settings,s=e._data,a=i._release,l=i._migrate,d=r._element,f=o.dragContainer||d,u=L(f,!0),h=f!==d?E(u,d):0,c=S(n,"x"),_=S(n,"y"),p=n.getBoundingClientRect();return i.isPositioning()&&i._stopLayout(!0,{transform:I(c,_)}),l.isActive&&(c-=l.containerDiffX,_-=l.containerDiffY,l.stop(!0,{transform:I(c,_)})),i.isReleasing()&&a.reset(),s.isActive=!0,s.startEvent=s.currentEvent=t,s.container=f,s.containingBlock=u,s.elementClientX=p.left,s.elementClientY=p.top,s.left=s.gridX=c,s.top=s.gridY=_,r._emit("dragInit",i,t),f!==d&&(s.containerDiffX=h.left,s.containerDiffY=h.top,n.parentNode===f?(s.gridX=c-s.containerDiffX,s.gridY=_-s.containerDiffY):(s.left=c+s.containerDiffX,s.top=_+s.containerDiffY,f.appendChild(n),C(n,{transform:I(s.left,s.top)}))),A(n,o.itemDraggingClass),e.bindScrollListeners(),r._emit("dragStart",i,t),e},d.prototype.onMove=function(t){var e=this,i=e.getItem();if(!i._isActive)return e.stop();var n=i._element,r=e.getGrid(),o=r._settings,s=e._data,a=o.dragAxis,l=t.deltaX-s.currentEvent.deltaX,d=t.deltaY-s.currentEvent.deltaY;return dt.add(ut,i._id,function(){s.currentEvent=t,"y"!==a&&(s.left+=l,s.gridX+=l,s.elementClientX+=l),"x"!==a&&(s.top+=d,s.gridY+=d,s.elementClientY+=d),o.dragSort&&e._checkSortOverlap()},function(){C(n,{transform:I(s.left,s.top)}),r._emit("dragMove",i,t)}),e},d.prototype.onScroll=function(t){var e,i,n,r,o=this,s=o.getItem(),a=s._element,l=o.getGrid(),d=l._settings,f=d.dragAxis,u=o._data,h=l._element;return dt.add(ht,s._id,function(){e=a.getBoundingClientRect(),i=u.elementClientX-e.left,n=u.elementClientY-e.top,u.container!==h&&(r=E(u.containingBlock,h),u.containerDiffX=r.left,u.containerDiffY=r.top),"y"!==f&&(u.left+=i,u.gridX=u.left-u.containerDiffX),"x"!==f&&(u.top+=n,u.gridY=u.top-u.containerDiffY),d.dragSort&&o._checkSortOverlap()},function(){C(a,{transform:I(u.left,u.top)}),l._emit("dragScroll",s,t)}),o},d.prototype.onEnd=function(t){var e=this,i=e.getItem(),n=i._element,r=e.getGrid(),o=r._settings,s=e._data,a=i._release;return i._isActive?(e.cancelRafLoop(),o.dragSort&&e._checkSortOverlap("finish"),e.unbindScrollListeners(),a.containerDiffX=s.containerDiffX,a.containerDiffY=s.containerDiffY,e.reset(),x(n,o.itemDraggingClass),r._emit("dragEnd",i,t),e._isMigrating?e.finishMigration():a.start(),e):e.stop()},Z.getSlot=function(t,e,i,n,r,o){var s,a,l,d,f,u=[],h={left:null,top:null,width:i,height:n};for(d=0;d<e.length;d++)if(s=e[d],h.width<=s.width+.001&&h.height<=s.height+.001){h.left=s.left,h.top=s.top;break}for(null===h.left&&(h.left=r?0:t.width,h.top=r?t.height:0,o||(l=!0)),r&&h.top+h.height>t.height&&(h.left>0&&u.push({left:0,top:t.height,width:h.left,height:1/0}),h.left+h.width<t.width&&u.push({left:h.left+h.width,top:t.height,width:t.width-h.left-h.width,height:1/0}),t.height=h.top+h.height),!r&&h.left+h.width>t.width&&(h.top>0&&u.push({left:t.width,top:0,width:1/0,height:h.top}),h.top+h.height<t.height&&u.push({left:t.width,top:h.top+h.height,width:1/0,height:t.height-h.top-h.height}),t.width=h.left+h.width),d=o?0:l?e.length:d;d<e.length;d++)for(a=Z.splitRect(e[d],h),f=0;f<a.length;f++)(s=a[f]).width>.49&&s.height>.49&&(r&&s.top<t.height||!r&&s.left<t.width)&&u.push(s);return u.length&&(u=Z.purgeRects(u).sort(r?Z.sortRectsTopLeft:Z.sortRectsLeftTop)),[h,u]},Z.splitRect=function(t,e){var i=[];return Z.doRectsOverlap(t,e)?(t.left<e.left&&i.push({left:t.left,top:t.top,width:e.left-t.left,height:t.height}),t.left+t.width>e.left+e.width&&i.push({left:e.left+e.width,top:t.top,width:t.left+t.width-(e.left+e.width),height:t.height}),t.top<e.top&&i.push({left:t.left,top:t.top,width:t.width,height:e.top-t.top}),t.top+t.height>e.top+e.height&&i.push({left:t.left,top:e.top+e.height,width:t.width,height:t.top+t.height-(e.top+e.height)}),i):[{left:t.left,top:t.top,width:t.width,height:t.height}]},Z.doRectsOverlap=function(t,e){return!(t.left+t.width<=e.left||e.left+e.width<=t.left||t.top+t.height<=e.top||e.top+e.height<=t.top)},Z.isRectWithinRect=function(t,e){return t.left>=e.left&&t.top>=e.top&&t.left+t.width<=e.left+e.width&&t.top+t.height<=e.top+e.height},Z.purgeRects=function(t){for(var e,i,n,r=t.length;r--;)for(i=t[r],e=t.length;e--;)if(n=t[e],r!==e&&Z.isRectWithinRect(i,n)){t.splice(r,1);break}return t},Z.sortRectsTopLeft=function(t,e){return t.top-e.top||t.left-e.left},Z.sortRectsLeftTop=function(t,e){return t.left-e.left||t.top-e.top},n}); | ||
!function(t,e){var i;if("object"==typeof module&&module.exports){try{i=require("hammerjs")}catch(t){}module.exports=e("Muuri",i)}else"function"==typeof define&&define.amd?define(["hammerjs"],function(t){return e("Muuri",t)}):t.Muuri=e("Muuri",t.Hammer)}("undefined"!=typeof window?window:this,function(t,e,i){"use strict";function n(t,e){var i,r,o,s=this;if(ot||(ot=document.body,It=G()),t=s._element=typeof t===at?nt.querySelector(t):t,!ot.contains(t))throw new et("Container element must be an existing DOM element");typeof(i=s._settings=W(n.defaultOptions,e)).dragSort!==st&&(i.dragSort=!!i.dragSort),mt[s._id=++Dt]=s,s._isDestroyed=!1,s._layout=null,s._emitter=new n.Emitter,s._itemShowHandler=F("show",i),s._itemHideHandler=F("hide",i),A(t,i.containerClass),s._items=[],typeof(r=i.items)===at?H(s._element.children).forEach(function(t){("*"===r||wt(t,r))&&s._items.push(new n.Item(s,t))}):(K.isArray(r)||p(r))&&(s._items=H(r).map(function(t){return new n.Item(s,t)})),(o=!0===(o=i.layoutOnResize)?0:typeof o===lt?o:-1)>=0&&$.addEventListener("resize",s._resizeHandler=y(function(){s.refreshItems().layout()},o)),i.layoutOnInit&&s.layout(!0)}function r(t,e){var i,r=this,o=t._settings;r._id=++Dt,yt[r._id]=r,r._isDestroyed=!1,e.parentNode!==t._element&&t._element.appendChild(e),A(e,o.itemClass),A(e,(i="none"===D(e,"display"))?o.itemHiddenClass:o.itemVisibleClass),r._gridId=t._id,r._element=e,r._child=e.children[0],r._animate=new n.ItemAnimate(r,e),r._animateChild=new n.ItemAnimate(r,r._child),r._isActive=!i,r._isPositioning=!1,r._isHidden=i,r._isHiding=!1,r._isShowing=!1,r._visibilityQueue=[],r._layoutQueue=[],r._left=0,r._top=0,C(e,{left:"0",top:"0",transform:I(0,0),display:i?"none":"block"}),r._refreshDimensions()._refreshSortData(),i?t._itemHideHandler.start(r,!0):t._itemShowHandler.start(r,!0),r._migrate=new n.ItemMigrate(r),r._release=new n.ItemRelease(r),r._drag=o.dragEnabled?new n.ItemDrag(r):null}function o(){this._events={},this._isDestroyed=!1}function s(t,e){var i=this;i._item=t,i._element=e,i._animation=null,i._propsTo=null,i._isDestroyed=!1}function a(t){var e=this;e._itemId=t._id,e._isDestroyed=!1,e.isActive=!1,e.container=!1,e.containerDiffX=0,e.containerDiffY=0}function l(t){var e=this;e._itemId=t._id,e._isDestroyed=!1,e.isActive=!1,e.isPositioningStarted=!1,e.containerDiffX=0,e.containerDiffY=0}function d(i){if(!e)throw new et("["+t+"] required dependency Hammer is not defined.");var n,r,o=this,s=i._element,a=i.getGrid(),l=a._settings,f=typeof l.dragStartPredicate===st?l.dragStartPredicate:d.defaultStartPredicate,u=ct;o._itemId=i._id,o._gridId=a._id,o._hammer=n=new e.Manager(s),o._isDestroyed=!1,o._isMigrating=!1,o._data={},o._resolveStartPredicate=function(t){o._isDestroyed||u!==_t||(u=pt,o.onStart(t))},o._scrollListener=function(t){o.onScroll(t)},o._checkSortOverlap=y(function(){o._data.isActive&&o.checkOverlap()},l.dragSortInterval),o._sortPredicate=typeof l.dragSortPredicate===st?l.dragSortPredicate:d.defaultSortPredicate,o.reset(),n.add(new e.Pan({event:"drag",pointers:1,threshold:0,direction:e.DIRECTION_ALL})),n.add(new e.Press({event:"draginit",pointers:1,threshold:1e3,time:0})),_(l.dragHammerSettings)&&n.set(l.dragHammerSettings),n.on("draginit dragstart dragmove",function(t){u===ct&&(u=_t),u===_t?!0===(r=f(o.getItem(),t))?(u=pt,o.onStart(t)):!1===r&&(u=gt):u===pt&&o._data.isActive&&o.onMove(t)}).on("dragend dragcancel draginitup",function(t){var e=u===pt;f(o.getItem(),t),u=ct,e&&o._data.isActive&&o.onEnd(t)}),s.addEventListener("dragstart",j,!1)}function f(t,e,i){var n=t.length,r=tt.max(0,i?n:n-1);return e>r?r:e<0?tt.max(r+e+1,0):e}function u(t,e,i){if(!(t.length<2)){var n,r=f(t,e),o=f(t,i);r!==o&&(n=t[r],t[r]=t[o],t[o]=n)}}function h(t,e,i){if(!(t.length<2)){var n=f(t,e),r=f(t,i);n!==r&&t.splice(r,0,t.splice(n,1)[0])}}function c(t){var e,i=[],n=t.length;if(n)for(i[0]=t[0],e=1;e<n;e++)i.indexOf(t[e])<0&&i.push(t[e]);return i}function _(t){return"object"==typeof t&&"[object Object]"===J.prototype.toString.call(t)}function p(t){var e=J.prototype.toString.call(t);return"[object HTMLCollection]"===e||"[object NodeList]"===e}function g(t,e){return J.keys(e).forEach(function(i){var n=_(e[i]);_(t[i])&&n?(t[i]=g({},t[i]),t[i]=g(t[i],e[i])):t[i]=n?g({},e[i]):K.isArray(e[i])?e[i].concat():e[i]}),t}function m(t,e,i){var n=typeof i===lt?i:-1;t.splice.apply(t,[n<0?t.length-n+1:n,0].concat(e))}function y(t,e){var n;return e>0?function(r){n!==i&&(n=$.clearTimeout(n),"finish"===r&&t()),"cancel"!==r&&"finish"!==r&&(n=$.setTimeout(function(){n=i,t()},e))}:function(e){"cancel"!==e&&t()}}function v(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function D(t,e){return $.getComputedStyle(t,null).getPropertyValue("transform"===e?St.styleName||e:e)}function w(t,e){return parseFloat(D(t,e))||0}function S(t,e){return parseFloat((D(t,"transform")||"").replace("matrix(","").split(",")["x"===e?4:5])||0}function I(t,e){return"translateX("+t+"px) translateY("+e+"px)"}function b(t,e){var i,n={},r=J.keys(e);for(i=0;i<r.length;i++)n[r[i]]=D(t,v(r[i]));return n}function C(t,e){var i,n=J.keys(e);for(i=0;i<n.length;i++)t.style["transform"===n[i]&&St?St.propName:n[i]]=e[n[i]]}function A(t,e){t.classList?t.classList.add(e):wt(t,"."+e)||(t.className+=" "+e)}function x(t,e){t.classList?t.classList.remove(e):wt(t,"."+e)&&(t.className=(" "+t.className+" ").replace(" "+e+" "," ").trim())}function H(t){return[].slice.call(t)}function E(t,e,i){if(t===e)return{left:0,top:0};i&&(t=L(t,!0),e=L(e,!0));var n=R(t,!0),r=R(e,!0);return{left:r.left-n.left,top:r.top-n.top}}function R(t,e){var i,n={left:0,top:0};return t===nt?n:(n.left=$.pageXOffset||0,n.top=$.pageYOffset||0,t.self===$.self?n:(i=t.getBoundingClientRect(),n.left+=i.left,n.top+=i.top,e&&(n.left+=w(t,"border-left-width"),n.top+=w(t,"border-top-width")),n))}function L(t,e){for(var i=(e?t:t.parentElement)||nt;i&&i!==nt&&"static"===D(i,"position")&&!X(i);)i=i.parentElement||nt;return i}function P(t){var e=[],i=/(auto|scroll)/,n=t.parentNode;if(It){if("fixed"===D(t,"position"))return e;for(;n&&n!==nt&&n!==rt;)i.test(D(n,"overflow")+D(n,"overflow-y")+D(n,"overflow-x"))&&e.push(n),n="fixed"===D(n,"position")?null:n.parentNode;null!==n&&e.push($)}else{for(;n&&n!==nt;)"fixed"!==D(t,"position")||X(n)?(i.test(D(n,"overflow")+D(n,"overflow-y")+D(n,"overflow-x"))&&e.push(n),t=n,n=n.parentNode):n=n.parentNode;e[e.length-1]===rt?e[e.length-1]=$:e.push($)}return e}function G(){if(!St)return!0;var t=[0,1].map(function(t,e){return t=nt.createElement("div"),C(t,{position:e?"fixed":"absolute",display:"block",visibility:"hidden",left:e?"0px":"1px",transform:"none"}),t}),e=ot.appendChild(t[0]),i=e.appendChild(t[1]),n=i.getBoundingClientRect().left;C(e,{transform:"scale(1)"});var r=n===i.getBoundingClientRect().left;return ot.removeChild(e),r}function X(t){var e=D(t,"transform"),i=D(t,"display");return"none"!==e&&"inline"!==i&&"none"!==i}function Y(t,e){return Z.doRectsOverlap(t,e)?(tt.min(t.left+t.width,e.left+e.width)-tt.max(t.left,e.left))*(tt.min(t.top+t.height,e.top+e.height)-tt.max(t.top,e.top))/(tt.min(t.width,e.width)*tt.min(t.height,e.height))*100:0}function O(t){var e,i={};for(e=0;e<t.length;e++)i[t[e]._id]=e;return i}function k(t,e,i,n){var r=n[t._id],o=n[e._id];return i?o-r:r-o}function M(t,e,i,n){var r,o,s,a,l,d=0;for(l=0;l<n.length;l++)if(r=n[l][0],o=n[l][1],s=(t._sortData?t:t._refreshSortData())._sortData[r],a=(e._sortData?e:e._refreshSortData())._sortData[r],0!==(d="desc"===o||!o&&i?a<s?-1:a>s?1:0:s<a?-1:s>a?1:0))return d;return d}function N(t,e){var i,n,r,o=[],s=t.concat();for(r=0;r<e.length;r++)i=e[r],(n=s.indexOf(i))>-1&&(o.push(i),s.splice(n,1));return t.splice.apply(t,[0,t.length].concat(o).concat(s)),t}function T(t,e,i){return i.width&&i.height&&t>=i.left&&t<i.left+i.width&&e>=i.top&&e<i.top+i.height}function z(t,e,n,r){var o,s,a=t.getItems(n),l=r||{},d=!0===l.instant,f=l.onFinish,u=l.layout?l.layout:l.layout===i,h=a.length,c="show"===e,_=c?Ct:xt,p=c?At:Ht,g=!1,m=[],y=[];if(h){for(t._emit(_,a.concat()),s=0;s<a.length;s++)o=a[s],(c&&!o._isActive||!c&&o._isActive)&&(g=!0),c&&!o._isActive&&(o._skipNextLayoutAnimation=!0),c&&o._isHidden&&y.push(o),o["_"+e](d,function(e,i){e||m.push(i),--h<1&&(typeof f===st&&f(m.concat()),t._emit(p,m.concat()))});y.length&&t.refreshItems(y),g&&u&&t.layout("instant"===u,typeof u===st?u:i)}else typeof f===st&&f(a);return t}function F(t,e){var i,n="show"===t,r=parseInt(n?e.showDuration:e.hideDuration)||0,o=(n?e.showEasing:e.hideEasing)||"ease",s=n?e.visibleStyles:e.hiddenStyles,a=r>0;return s=_(s)?s:null,{start:function(t,e,n){s?(dt.cancel(ft,t._id),!a||e?(t._animateChild.isAnimating()?t._animateChild.stop(s):C(t._child,s),n&&n()):dt.add(ft,t._id,function(){i=b(t._child,s)},function(){t._animateChild.start(i,s,{duration:r,easing:o,onFinish:n})})):n&&n()},stop:function(t,e){dt.cancel(ft,t._id),t._animateChild.stop(e)}}}function B(t,e,i,n){var r,o,s,a=null,l=e._settings.dragSort,d=!0===l?[e]:l.call(e,t),f=-1;if(!K.isArray(d))return a;for(s=0;s<d.length;s++)(o=d[s])._isDestroyed||(o._refreshDimensions(),(r=Y(i,{width:o._width,height:o._height,left:o._left,top:o._top}))>n&&r>f&&(f=r,a=o));return a}function V(t,e,i){var n,r=t.splice(0,t.length);for(n=0;n<r.length;n++)r[n](e,i)}function Q(t,e){var i;return"inactive"===e?!t.isActive():"hidden"===e?!t.isVisible():(i="is"+e.charAt(0).toUpperCase()+e.slice(1),typeof t[i]===st&&t[i]())}function j(t){t.preventDefault&&t.preventDefault()}function W(t,e){var i=g({},t);return i=e?g(i,e):i,i.visibleStyles=(e||{}).visibleStyles||(t||{}).visibleStyles,i.hiddenStyles=(e||{}).hiddenStyles||(t||{}).hiddenStyles,i}function q(t,e){var i,n=t._drag._startPredicateData;if(!(e.distance<n.distance||n.delay))return i=n.handleElement.getBoundingClientRect(),U(t),T(e.srcEvent.pageX,e.srcEvent.pageY,{width:i.width,height:i.height,left:i.left+($.pageXOffset||0),top:i.top+($.pageYOffset||0)})}function U(t){var e=t._drag._startPredicateData;e&&(e.delayTimer&&(e.delayTimer=$.clearTimeout(e.delayTimer)),t._drag._startPredicateData=null)}function Z(t,e,i,n){var r,o,s,a,l,d,f,u=!!n.fillGaps,h=!!n.horizontal,c=!!n.alignRight,_=!!n.alignBottom,p=!!n.rounding,g={slots:{},width:h?0:p?tt.round(e):e,height:h?p?tt.round(i):i:0,setWidth:h,setHeight:!h},m=[];if(!t.length)return g;for(f=0;f<t.length;f++)l=(a=t[f])._width+a._margin.left+a._margin.right,d=a._height+a._margin.top+a._margin.bottom,p&&(l=tt.round(l),d=tt.round(d)),s=(o=Z.getSlot(g,m,l,d,!h,u))[0],m=o[1],h?g.width=tt.max(g.width,s.left+s.width):g.height=tt.max(g.height,s.top+s.height),g.slots[a._id]=s;if(c||_)for(r=J.keys(g.slots),f=0;f<r.length;f++)s=g.slots[r[f]],c&&(s.left=g.width-(s.left+s.width)),_&&(s.top=g.height-(s.top+s.height));return g}var $=window,J=$.Object,K=$.Array,tt=$.Math,et=$.Error,it=$.Element,nt=$.document,rt=nt.documentElement,ot=nt.body,st="function",at="string",lt="number",dt=function(){function t(){var a,l=+n._maxRafBatchSize||100,d=r.splice(0,tt.min(l,r.length)),f={};for(e=null,a=0;a<d.length;a++)f[d[a]]=o[d[a]],o[d[a]]=i;for(a=0;a<d.length;a++)f[d[a]][0]();for(a=0;a<d.length;a++)f[d[a]][1]();!e&&r.length&&(e=s(t))}var e=null,r=[],o={},s=($.requestAnimationFrame||$.webkitRequestAnimationFrame||$.mozRequestAnimationFrame||$.msRequestAnimationFrame||function(t){return $.setTimeout(t,16)}).bind($);return{add:function(i,n,a,l){var d=r.indexOf(i+n);d>-1&&r.splice(d,1),i===ut||i===ht?r.unshift(i+n):r.push(i+n),o[i+n]=[a,l],!e&&(e=s(t))},cancel:function(t,e){var n=r.indexOf(t+e);n>-1&&(r.splice(n,1),o[t+e]=i)}}}(),ft="visibility",ut="move",ht="scroll",ct=0,_t=1,pt=2,gt=3,mt={},yt={},vt=function(){},Dt=0,wt=function(){var t=it.prototype,e=t.matches||t.matchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector;return function(t,i){return e.call(t,i)}}(),St=function(t){var e,n,r,o=t.charAt(0).toUpperCase()+t.slice(1),s=["","Webkit","Moz","O","ms"];for(r=0;r<s.length;r++)if(e=s[r],n=e?e+o:t,rt.style[n]!==i)return e=e.toLowerCase(),{prefix:e,propName:n,styleName:e?"-"+e+"-"+t:t};return null}("transform"),It=ot?G():null,bt="layoutEnd",Ct="showStart",At="showEnd",xt="hideStart",Ht="hideEnd";return n.Item=r,n.ItemDrag=d,n.ItemRelease=l,n.ItemMigrate=a,n.ItemAnimate=s,n.Layout=function(t,e){var i=this,n=t._settings.layout;e=e.concat(),t._refreshDimensions();var r=t._width-t._border.left-t._border.right,o=t._height-t._border.top-t._border.bottom,s=typeof n===st?n(e,r,o):Z(e,r,o,_(n)?n:{});i.slots=s.slots,i.setWidth=s.setWidth||!1,i.setHeight=s.setHeight||!1,i.width=s.width,i.height=s.height},n.Emitter=o,n.defaultOptions={items:"*",showDuration:300,showEasing:"ease",hideDuration:300,hideEasing:"ease",visibleStyles:{opacity:"1",transform:"scale(1)"},hiddenStyles:{opacity:"0",transform:"scale(0.5)"},layout:{fillGaps:!1,horizontal:!1,alignRight:!1,alignBottom:!1,rounding:!0},layoutOnResize:100,layoutOnInit:!0,layoutDuration:300,layoutEasing:"ease",sortData:null,dragEnabled:!1,dragContainer:null,dragStartPredicate:{distance:0,delay:0,handle:!1},dragAxis:null,dragSort:!0,dragSortInterval:100,dragSortPredicate:{threshold:50,action:"move"},dragReleaseDuration:300,dragReleaseEasing:"ease",dragHammerSettings:{touchAction:"none"},containerClass:"muuri",itemClass:"muuri-item",itemVisibleClass:"muuri-item-shown",itemHiddenClass:"muuri-item-hidden",itemPositioningClass:"muuri-item-positioning",itemDraggingClass:"muuri-item-dragging",itemReleasingClass:"muuri-item-releasing"},n._maxRafBatchSize=100,n.prototype.on=function(t,e){var i=this;return i._isDestroyed||i._emitter.on(t,e),i},n.prototype.once=function(t,e){var i=this;return i._isDestroyed||i._emitter.once(t,e),i},n.prototype.off=function(t,e){var i=this;return i._isDestroyed||i._emitter.off(t,e),i},n.prototype.getElement=function(){return this._element},n.prototype.getItems=function(t,e){var i=this;if(i._isDestroyed)return[];var n,r,o=0===t||t&&typeof t!==at,s=o?p(t)?H(t):[].concat(t):null,a=o?e:t,l=[];if((a=typeof a===at?a:null)||s){for(s=s||i._items,r=0;r<s.length;r++)!(n=o?i._getItem(s[r]):s[r])||a&&!Q(n,a)||l.push(n);return l}return l.concat(i._items)},n.prototype.refreshItems=function(t){var e=this;if(e._isDestroyed)return e;var i,n=e.getItems(t||"active");for(i=0;i<n.length;i++)n[i]._refreshDimensions();return e},n.prototype.refreshSortData=function(t){var e=this;if(e._isDestroyed)return e;var i,n=e.getItems(t);for(i=0;i<n.length;i++)n[i]._refreshSortData();return e},n.prototype.synchronize=function(){var t=this;if(t._isDestroyed)return t;var e,i,n,r=t._element,o=t._items;if(o.length){for(n=0;n<o.length;n++)(i=o[n]._element).parentNode===r&&(e=e||nt.createDocumentFragment()).appendChild(i);e&&r.appendChild(e)}return t._emit("synchronize"),t},n.prototype.layout=function(t,e){function i(){--_<=0&&(typeof f===st&&f(r._layout!==c,h.concat()),r._layout===c&&r._emit(bt,h.concat()))}var r=this;if(r._isDestroyed)return r;var o,s,a,l,d,f=typeof t===st?t:e,u=!0===t,h=r.getItems("active"),c=r._layout=new n.Layout(r,h),_=h.length;if((c.setWidth||c.setHeight)&&(s={},o="border-box"===D(r._element,"box-sizing"),c.setHeight&&(typeof c.height===lt?s.height=(o?c.height+r._border.top+r._border.bottom:c.height)+"px":s.height=c.height),c.setWidth&&(typeof c.width===lt?s.width=(o?c.width+r._border.left+r._border.right:c.width)+"px":s.width=c.width),C(r._element,s)),r._emit("layoutStart",h.concat()),!h.length)return i(),r;for(d=0;d<h.length;d++)a=h[d],l=c.slots[a._id],a._left=l.left,a._top=l.top,a.isDragging()?i():a._layout(u,i);return r},n.prototype.add=function(t,e){var r=this;if(r._isDestroyed)return[];var o=[].concat(t),s=[];if(!o.length)return s;var a,l,d,f=e||{},u=f.layout?f.layout:f.layout===i,h=r._items,c=!1;for(d=0;d<h.length;d++)if((a=o.indexOf(h[d]._element))>-1&&(o.splice(a,1),!o.length))return s;for(d=0;d<o.length;d++)l=new n.Item(r,o[d]),s.push(l),l._isActive&&(c=!0,l._skipNextLayoutAnimation=!0);return m(h,s,f.index),r._emit("add",s.concat()),c&&u&&r.layout("instant"===u,typeof u===st?u:i),s},n.prototype.remove=function(t,e){var n=this;if(n._isDestroyed)return n;var r,o,s=e||{},a=s.layout?s.layout:s.layout===i,l=!1,d=n.getItems(t);for(o=0;o<d.length;o++)(r=d[o])._isActive&&(l=!0),r._destroy(s.removeElements);return n._emit("remove",d.concat()),l&&a&&n.layout("instant"===a,typeof a===st?a:i),d},n.prototype.show=function(t,e){return this._isDestroyed?this:z(this,"show",t,e)},n.prototype.hide=function(t,e){return this._isDestroyed?this:z(this,"hide",t,e)},n.prototype.filter=function(t,e){var n=this;if(n._isDestroyed||!n._items.length)return n;var r,o,s=n._items,a=typeof t,l=a===at,d=a===st,f=e||{},u=!0===f.instant,h=f.layout?f.layout:f.layout===i,c=typeof f.onFinish===st?f.onFinish:null,_=[],p=[],g=-1,m=c?function(){++g&&c(_.concat(),p.concat())}:vt;if(d||l)for(o=0;o<s.length;o++)r=s[o],(d?t(r):wt(r._element,t))?_.push(r):p.push(r);return _.length?n.show(_,{instant:u,onFinish:m,layout:!1}):m(),p.length?n.hide(p,{instant:u,onFinish:m,layout:!1}):m(),(_.length||p.length)&&(n._emit("filter",_.concat(),p.concat()),h&&n.layout("instant"===h,typeof h===st?h:i)),n},n.prototype.sort=function(t,e){var n=this;if(n._isDestroyed||n._items.length<2)return n;var r,o=n._items,s=e||{},a=!!s.descending,l=s.layout?s.layout:s.layout===i,d=o.concat();if(typeof t===st)o.sort(function(e,i){var n=t(e,i);return(a&&0!==n?-n:n)||k(e,i,a,r||(r=O(d)))});else if(typeof t===at)t=t.trim().split(" ").map(function(t){return t.split(":")}),o.sort(function(e,i){return M(e,i,a,t)||k(e,i,a,r||(r=O(d)))});else{if(!K.isArray(t))return n;N(o,t),a&&o.reverse()}return n._emit("sort",o.concat(),d),l&&n.layout("instant"===l,typeof l===st?l:i),n},n.prototype.move=function(t,e,n){var r=this;if(r._isDestroyed||r._items.length<2)return r;var o,s,a=r._items,l=n||{},d=l.layout?l.layout:l.layout===i,f="swap"===l.action,c=f?"swap":"move",_=r._getItem(t),p=r._getItem(e);return _&&p&&_!==p&&(o=a.indexOf(_),s=a.indexOf(p),(f?u:h)(a,o,s),r._emit("move",{item:_,fromIndex:o,toIndex:s,action:c}),d&&r.layout("instant"===d,typeof d===st?d:i)),r},n.prototype.send=function(t,e,n,r){var o=this;if(o._isDestroyed||e._isDestroyed||o===e||!(t=o._getItem(t)))return o;var s=e,a=r||{},l=a.appendTo||ot,d=a.layoutSender?a.layoutSender:a.layoutSender===i,f=a.layoutReceiver?a.layoutReceiver:a.layoutReceiver===i;return t._migrate.start(s,n,l),t._migrate.isActive&&t.isActive()&&(d&&o.layout("instant"===d,typeof d===st?d:i),f&&s.layout("instant"===f,typeof f===st?f:i)),o},n.prototype.destroy=function(t){var e=this;if(e._isDestroyed)return e;var n,r=e._element,o=e._items.concat();for(e._resizeHandler&&$.removeEventListener("resize",e._resizeHandler),n=0;n<o.length;n++)o[n]._destroy(t);return x(r,e._settings.containerClass),C(r,{height:""}),e._emit("destroy"),e._emitter.destroy(),mt[e._id]=i,e._isDestroyed=!0,e},n.prototype._getItem=function(t){var e,i=this,n=i._items;if(i._isDestroyed||!t)return n[0]||null;if(typeof t===lt)return n[t>-1?t:n.length+t]||null;if(t instanceof r)return t._gridId===i._id?t:null;for(e=0;e<n.length;e++)if(n[e]._element===t)return n[e];return null},n.prototype._emit=function(){var t=this;return t._isDestroyed||t._emitter.emit.apply(t._emitter,arguments),t},n.prototype._refreshDimensions=function(){var t,e=this,i=e._element,n=i.getBoundingClientRect(),r=["left","right","top","bottom"];for(e._width=n.width,e._height=n.height,e._left=n.left,e._top=n.top,e._border={},t=0;t<r.length;t++)e._border[r[t]]=w(i,"border-"+r[t]+"-width");return e},r.prototype.getGrid=function(){return mt[this._gridId]},r.prototype.getElement=function(){return this._element},r.prototype.getWidth=function(){return this._width},r.prototype.getHeight=function(){return this._height},r.prototype.getMargin=function(){return{left:this._margin.left,right:this._margin.right,top:this._margin.top,bottom:this._margin.bottom}},r.prototype.getPosition=function(){return{left:this._left,top:this._top}},r.prototype.isActive=function(){return this._isActive},r.prototype.isVisible=function(){return!this._isHidden},r.prototype.isShowing=function(){return this._isShowing},r.prototype.isHiding=function(){return this._isHiding},r.prototype.isPositioning=function(){return this._isPositioning},r.prototype.isDragging=function(){return!!this._drag&&this._drag._data.isActive},r.prototype.isReleasing=function(){return this._release.isActive},r.prototype.isDestroyed=function(){return this._isDestroyed},r.prototype._refreshDimensions=function(){var t=this;if(t._isDestroyed||t._isHidden)return t;var e,i,n=t._element,r=n.getBoundingClientRect(),o=["left","right","top","bottom"],s=t._margin=t._margin||{};for(t._width=r.width,t._height=r.height,i=0;i<4;i++)e=w(n,"margin-"+o[i]),s[o[i]]=e>0?e:0;return t},r.prototype._refreshSortData=function(){var t=this;if(t._isDestroyed)return t;var e={},i=t.getGrid()._settings.sortData;return i&&J.keys(i).forEach(function(n){e[n]=i[n](t,t._element)}),t._sortData=e,t},r.prototype._layout=function(t,e){var i=this;if(i._isDestroyed)return i;var n,r,o,s,a,l,d=i._element,f=i._isPositioning,u=i._migrate,h=i._release,c=h.isActive&&!1===h.isPositioningStarted,_=i.getGrid()._settings,p=c?_.dragReleaseDuration:_.layoutDuration,g=c?_.dragReleaseEasing:_.layoutEasing,m=!t&&!i._skipNextLayoutAnimation&&p>0;return f&&V(i._layoutQueue,!0,i),c&&(h.isPositioningStarted=!0),typeof e===st&&i._layoutQueue.push(e),r=h.isActive?h.containerDiffX:u.isActive?u.containerDiffX:0,o=h.isActive?h.containerDiffY:u.isActive?u.containerDiffY:0,l={transform:I(i._left+r,i._top+o)},m?(i._isPositioning=!0,dt.add("layout",i._id,function(){s=S(d,"x")-r,a=S(d,"y")-o},function(){if(i._left===s&&i._top===a)return f&&i._stopLayout(!1,l),i._isPositioning=!1,i._finishLayout();!f&&A(d,_.itemPositioningClass),i._animate.start({transform:I(s+r,a+o)},l,{duration:p,easing:g,onFinish:function(){i._finishLayout()}})}),i):(f&&dt.cancel("layout",i._id),n=i._animate.isAnimating(),i._stopLayout(!1,l),!n&&C(d,l),i._skipNextLayoutAnimation=!1,i._finishLayout())},r.prototype._finishLayout=function(){var t=this;return t._isDestroyed?t:(t._isPositioning&&(t._isPositioning=!1,x(t._element,t.getGrid()._settings.itemPositioningClass)),t._release.isActive&&t._release.stop(),t._migrate.isActive&&t._migrate.stop(),V(t._layoutQueue,!1,t),t)},r.prototype._stopLayout=function(t,e){var i=this;return i._isDestroyed||!i._isPositioning?i:(dt.cancel("layout",i._id),i._animate.stop(e),x(i._element,i.getGrid()._settings.itemPositioningClass),i._isPositioning=!1,t&&V(i._layoutQueue,!0,i),i)},r.prototype._show=function(t,e){var i=this;if(i._isDestroyed)return i;var n=i._element,r=i._visibilityQueue,o=typeof e===st?e:null,s=i.getGrid(),a=s._settings;return i._isShowing||i._isHidden?i._isShowing&&!t?(o&&r.push(o),i):(i._isShowing||(V(r,!0,i),x(n,a.itemHiddenClass),A(n,a.itemVisibleClass),!i._isHiding&&C(n,{display:"block"})),o&&r.push(o),i._isActive=i._isShowing=!0,i._isHiding=i._isHidden=!1,t?(s._itemShowHandler.stop(i,a.visibleStyles),i._isShowing=!1,V(r,!1,i)):s._itemShowHandler.start(i,t,function(){i._isHidden||(i._isShowing=!1,V(r,!1,i))}),i):(o&&o(!1,i),i)},r.prototype._hide=function(t,e){var i=this;if(i._isDestroyed)return i;var n=i._element,r=i._visibilityQueue,o=typeof e===st?e:null,s=i.getGrid(),a=s._settings;return!i._isHiding&&i._isHidden?(o&&o(!1,i),i):i._isHiding&&!t?(o&&r.push(o),i):(i._isHiding||(V(r,!0,i),A(n,a.itemHiddenClass),x(n,a.itemVisibleClass)),o&&r.push(o),i._isHidden=i._isHiding=!0,i._isActive=i._isShowing=!1,t?(s._itemHideHandler.stop(i,a.hiddenStyles),i._isHiding=!1,i._stopLayout(!0,{transform:I(0,0)}),C(n,{display:"none"}),V(r,!1,i)):s._itemHideHandler.start(i,t,function(){i._isHidden&&(i._isHiding=!1,i._stopLayout(!0,{transform:I(0,0)}),C(n,{display:"none"}),V(r,!1,i))}),i)},r.prototype._destroy=function(t){var e=this;if(e._isDestroyed)return e;var n=e._element,r=e.getGrid(),o=r._settings,s=r._items.indexOf(e);return e._release.destroy(),e._migrate.destroy(),e._stopLayout(!0,{}),r._itemShowHandler.stop(e,{}),r._itemHideHandler.stop(e,{}),e._drag&&e._drag.destroy(),e._animate.destroy(),e._animateChild.destroy(),V(e._visibilityQueue,!0,e),n.removeAttribute("style"),e._child.removeAttribute("style"),x(n,o.itemPositioningClass),x(n,o.itemDraggingClass),x(n,o.itemReleasingClass),x(n,o.itemClass),x(n,o.itemVisibleClass),x(n,o.itemHiddenClass),s>-1&&r._items.splice(s,1),t&&n.parentNode.removeChild(n),yt[e._id]=i,e._isActive=e._isPositioning=e._isHiding=e._isShowing=!1,e._isDestroyed=e._isHidden=!0,e},o.prototype.on=function(t,e){var i=this;if(i._isDestroyed)return i;var n=i._events[t]||[];return n.push(e),i._events[t]=n,i},o.prototype.once=function(t,e){var i=this;return this.on(t,function n(){i.off(t,n),e.apply(null,arguments)})},o.prototype.off=function(t,e){var i=this;if(i._isDestroyed)return i;for(var n=i._events[t]||[],r=n.length;r--;)e===n[r]&&n.splice(r,1);return i},o.prototype.emit=function(t,e,i,n){var r=this;if(r._isDestroyed)return r;var o,s=r._events[t]||[],a=s.length,l=arguments.length-1;if(a)for(s=s.concat(),o=0;o<a;o++)0===l?s[o]():1===l?s[o](e):2===l?s[o](e,i):s[o](e,i,n);return r},o.prototype.destroy=function(){var t=this;if(t._isDestroyed)return t;var e,i=J.keys(t._events);for(e=0;e<i.length;e++)t._events[i[e]]=null;return t._isDestroyed=!0,t},s.prototype.start=function(t,e,i){var n=this;if(!n._isDestroyed){var r=i||{},o=typeof r.onFinish===st?r.onFinish:null;if(n._animation){if(!J.keys(e).some(function(t){return e[t]!==n._propsTo[t]}))return void(n._animation.onfinish=function(){n._animation=n._propsTo=null,o&&o()});n._animation.cancel()}n._propsTo=e,n._animation=n._element.animate([t,e],{duration:r.duration||300,easing:r.easing||"ease"}),n._animation.onfinish=function(){n._animation=n._propsTo=null,o&&o()},C(n._element,e)}},s.prototype.stop=function(t){var e=this;!e._isDestroyed&&e._animation&&(C(e._element,t||b(e._element,e._propsTo)),e._animation.cancel(),e._animation=e._propsTo=null)},s.prototype.isAnimating=function(){return!!this._animation},s.prototype.destroy=function(){var t=this;t._isDestroyed||(t.stop(),t._item=t._element=null,t._isDestroyed=!0)},a.prototype.destroy=function(){var t=this;return t._isDestroyed||(t.stop(!0),t._isDestroyed=!0),t},a.prototype.getItem=function(){return yt[this._itemId]||null},a.prototype.start=function(t,e,r){var o=this;if(o._isDestroyed)return o;var s,a,l,d,u,h=o.getItem(),c=h._element,_=h.isVisible(),p=h.getGrid(),g=p._settings,y=t._settings,v=t._element,D=p._items.indexOf(h),w=typeof e===lt?e:t._items.indexOf(t._getItem(e)),b=r||ot;return null===w?o:(w=f(t._items,w,!0),(h.isPositioning()||o.isActive||h.isReleasing())&&(d=S(c,"x"),u=S(c,"y")),h.isPositioning()&&h._stopLayout(!0,{transform:I(d,u)}),o.isActive&&(d-=o.containerDiffX,u-=o.containerDiffY,o.stop(!0,{transform:I(d,u)})),h.isReleasing()&&(d-=h._release.containerDiffX,u-=h._release.containerDiffY,h._release.stop(!0,{transform:I(d,u)})),p._itemShowHandler.stop(h),p._itemHideHandler.stop(h),h._drag&&h._drag.destroy(),h._animate.destroy(),h._animateChild.destroy(),V(h._visibilityQueue,!0,h),p._emit("beforeSend",{item:h,fromGrid:p,fromIndex:D,toGrid:t,toIndex:w}),t._emit("beforeReceive",{item:h,fromGrid:p,fromIndex:D,toGrid:t,toIndex:w}),x(c,g.itemClass),x(c,g.itemVisibleClass),x(c,g.itemHiddenClass),A(c,y.itemClass),A(c,_?y.itemVisibleClass:y.itemHiddenClass),p._items.splice(D,1),m(t._items,h,w),h._gridId=t._id,h._animate=new n.ItemAnimate(h,c),h._animateChild=new n.ItemAnimate(h,h._child),s=c.parentNode,b!==s&&(b.appendChild(c),a=E(b,s,!0),d===i&&(d=S(c,"x"),u=S(c,"y")),C(c,{transform:I(d+a.left,u+a.top)})),h._child.removeAttribute("style"),_?t._itemShowHandler.start(h,!0):t._itemHideHandler.start(h,!0),C(c,{display:_?"block":"hidden"}),l=E(b,v,!0),h._refreshDimensions()._refreshSortData(),h._drag=y.dragEnabled?new n.ItemDrag(h):null,o.isActive=!0,o.container=b,o.containerDiffX=l.left,o.containerDiffY=l.top,p._emit("send",{item:h,fromGrid:p,fromIndex:D,toGrid:t,toIndex:w}),t._emit("receive",{item:h,fromGrid:p,fromIndex:D,toGrid:t,toIndex:w}),o)},a.prototype.stop=function(t,e){var i=this;if(i._isDestroyed||!i.isActive)return i;var n=i.getItem(),r=n._element,o=n.getGrid()._element;return i.container!==o&&(e||(e={transform:I(t?S(r,"x")-i.containerDiffX:n._left,t?S(r,"y")-i.containerDiffY:n._top)}),o.appendChild(r),C(r,e)),i.isActive=!1,i.container=null,i.containerDiffX=0,i.containerDiffY=0,i},l.prototype.destroy=function(){var t=this;return t._isDestroyed||(t.stop(!0),t._isDestroyed=!0),t},l.prototype.getItem=function(){return yt[this._itemId]||null},l.prototype.reset=function(){var t=this;if(t._isDestroyed)return t;var e=t.getItem();return t.isActive=!1,t.isPositioningStarted=!1,t.containerDiffX=0,t.containerDiffY=0,x(e._element,e.getGrid()._settings.itemReleasingClass),t},l.prototype.start=function(){var t=this;if(t._isDestroyed||t.isActive)return t;var e=t.getItem(),i=e.getGrid();return t.isActive=!0,A(e._element,i._settings.itemReleasingClass),i._emit("dragReleaseStart",e),e._layout(!1),t},l.prototype.stop=function(t,e){var i=this;if(i._isDestroyed||!i.isActive)return i;var n=i.getItem(),r=n._element,o=n.getGrid(),s=o._element,a=i.containerDiffX,l=i.containerDiffY;return i.reset(),r.parentNode!==s&&(e||(e={transform:I(t?S(r,"x")-a:n._left,t?S(r,"y")-l:n._top)}),s.appendChild(r),C(r,e)),t||o._emit("dragReleaseEnd",n),i},d.defaultStartPredicate=function(t,e,i){var n,r,o,s,a=t._element,l=t._drag._startPredicateData;if(l||(n=_(n=i||t._drag.getGrid()._settings.dragStartPredicate)?n:{},l=t._drag._startPredicateData={distance:tt.abs(n.distance)||0,delay:tt.max(n.delay,0)||0,handle:"string"==typeof n.handle&&n.handle}),e.isFinal)return r="a"===a.tagName.toLowerCase(),o=a.getAttribute("href"),s=a.getAttribute("target"),U(t),void(r&&o&&tt.abs(e.deltaX)<2&&tt.abs(e.deltaY)<2&&e.deltaTime<200&&(s&&"_self"!==s?$.open(o,s):$.location.href=o));if(!l.handleElement)if(l.handle){for(l.handleElement=e.srcEvent.target;l.handleElement&&!wt(l.handleElement,l.handle);)l.handleElement=l.handleElement!==a?l.handleElement.parentElement:null;if(!l.handleElement)return!1}else l.handleElement=a;return l.delay&&(l.event=e,l.delayTimer||(l.delayTimer=$.setTimeout(function(){l.delay=0,q(t,l.event)&&(t._drag._resolveStartPredicate(l.event),U(t))},l.delay))),q(t,e)},d.defaultSortPredicate=function(t){var e,i,n,r,o,s=t._drag,a=s._data,l=s.getGrid(),d=l._settings.dragSortPredicate||{},f=d.threshold||50,u=d.action||"move",h={width:t._width,height:t._height,left:a.elementClientX,top:a.elementClientY},c=B(t,l,h,f),_=0,p=0,g=-1;if(!c)return!1;for(c===l?(h.left=a.gridX+t._margin.left,h.top=a.gridY+t._margin.top):(_=c._left+c._border.left,p=c._top+c._border.top),o=0;o<c._items.length;o++)(n=c._items[o])._isActive&&n!==t&&(i=!0,(r=Y(h,{width:n._width,height:n._height,left:n._left+n._margin.left+_,top:n._top+n._margin.top+p}))>g&&(e=o,g=r));return g<f&&t.getGrid()!==c&&(e=i?-1:0,g=1/0),g>=f&&{grid:c,index:e,action:u}},d.prototype.destroy=function(){var t=this;return t._isDestroyed||(t.stop(),t._hammer.destroy(),t.getItem()._element.removeEventListener("dragstart",j,!1),t._isDestroyed=!0),t},d.prototype.getItem=function(){return yt[this._itemId]||null},d.prototype.getGrid=function(){return mt[this._gridId]||null},d.prototype.reset=function(){var t=this,e=t._data;return e.isActive=!1,e.container=null,e.containingBlock=null,e.startEvent=null,e.currentEvent=null,e.scrollers=[],e.left=0,e.top=0,e.gridX=0,e.gridY=0,e.elementClientX=0,e.elementClientY=0,e.containerDiffX=0,e.containerDiffY=0,t},d.prototype.bindScrollListeners=function(){var t,e=this,i=e.getGrid()._element,n=e._data.container,r=P(e.getItem()._element);for(n!==i&&(r=c(r.concat(i).concat(P(i)))),t=0;t<r.length;t++)r[t].addEventListener("scroll",e._scrollListener);return e._data.scrollers=r,e},d.prototype.unbindScrollListeners=function(){var t,e=this,i=e._data,n=i.scrollers;for(t=0;t<n.length;t++)n[t].removeEventListener("scroll",e._scrollListener);return i.scrollers=[],e},d.prototype.checkOverlap=function(){var t,e,i,n,r,o,s=this,a=s.getItem(),l=s._sortPredicate(a,s._data.currentEvent);return _(l)&&typeof l.index===lt?(t=a.getGrid(),i=l.grid||t,o=t!==i,e=t._items.indexOf(a),n=f(t._items,l.index,o),r="swap"===l.action?"swap":"move",o?(t._emit("beforeSend",{item:a,fromGrid:t,fromIndex:e,toGrid:i,toIndex:n}),i._emit("beforeReceive",{item:a,fromGrid:t,fromIndex:e,toGrid:i,toIndex:n}),a._gridId=i._id,s._isMigrating=a._gridId!==s._gridId,t._items.splice(e,1),m(i._items,a,n),a._sortData=null,t._emit("send",{item:a,fromGrid:t,fromIndex:e,toGrid:i,toIndex:n}),i._emit("receive",{item:a,fromGrid:t,fromIndex:e,toGrid:i,toIndex:n}),t.layout(),i.layout()):e!==n&&(("swap"===r?u:h)(t._items,e,n),t._emit("move",{item:a,fromIndex:e,toIndex:n,action:r}),t.layout()),s):s},d.prototype.finishMigration=function(){var t,e,i,r=this,o=r.getItem(),s=o._release,a=o._element,l=o.getGrid(),d=l._element,f=l._settings,u=f.dragContainer||d,h=r.getGrid()._settings,c=a.parentNode;return r._isMigrating=!1,r.destroy(),o._animate.destroy(),o._animateChild.destroy(),x(a,h.itemClass),x(a,h.itemVisibleClass),x(a,h.itemHiddenClass),A(a,f.itemClass),A(a,f.itemVisibleClass),o._animate=new n.ItemAnimate(o,a),o._animateChild=new n.ItemAnimate(o,o._child),u!==c&&(u.appendChild(a),i=E(c,u,!0),t=S(a,"x")-i.left,e=S(a,"y")-i.top),o._refreshDimensions()._refreshSortData(),i=E(u,d,!0),s.containerDiffX=i.left,s.containerDiffY=i.top,o._drag=f.dragEnabled?new n.ItemDrag(o):null,u!==c&&C(a,{transform:I(t,e)}),o._child.removeAttribute("style"),l._itemShowHandler.start(o,!0),s.start(),r},d.prototype.cancelRafLoop=function(){var t=this.getItem()._id;return dt.cancel(ht,t),dt.cancel(ut,t),this},d.prototype.stop=function(){var t=this,e=t._data,i=t.getItem()._element,n=t.getGrid();return e.isActive?t._isMigrating?t.finishMigration(e.currentEvent):(t.cancelRafLoop(),t.unbindScrollListeners(),t._checkSortOverlap("cancel"),i.parentNode!==n._element&&(n._element.appendChild(i),C(i,{transform:I(e.gridX,e.gridY)})),x(i,n._settings.itemDraggingClass),t.reset(),t):t},d.prototype.onStart=function(t){var e=this,i=e.getItem();if(!i._isActive)return e;var n=i._element,r=e.getGrid(),o=r._settings,s=e._data,a=i._release,l=i._migrate,d=r._element,f=o.dragContainer||d,u=L(f,!0),h=f!==d?E(u,d):0,c=S(n,"x"),_=S(n,"y"),p=n.getBoundingClientRect();return i.isPositioning()&&i._stopLayout(!0,{transform:I(c,_)}),l.isActive&&(c-=l.containerDiffX,_-=l.containerDiffY,l.stop(!0,{transform:I(c,_)})),i.isReleasing()&&a.reset(),s.isActive=!0,s.startEvent=s.currentEvent=t,s.container=f,s.containingBlock=u,s.elementClientX=p.left,s.elementClientY=p.top,s.left=s.gridX=c,s.top=s.gridY=_,r._emit("dragInit",i,t),f!==d&&(s.containerDiffX=h.left,s.containerDiffY=h.top,n.parentNode===f?(s.gridX=c-s.containerDiffX,s.gridY=_-s.containerDiffY):(s.left=c+s.containerDiffX,s.top=_+s.containerDiffY,f.appendChild(n),C(n,{transform:I(s.left,s.top)}))),A(n,o.itemDraggingClass),e.bindScrollListeners(),r._emit("dragStart",i,t),e},d.prototype.onMove=function(t){var e=this,i=e.getItem();if(!i._isActive)return e.stop();var n=i._element,r=e.getGrid(),o=r._settings,s=e._data,a=o.dragAxis,l=t.deltaX-s.currentEvent.deltaX,d=t.deltaY-s.currentEvent.deltaY;return dt.add(ut,i._id,function(){s.currentEvent=t,"y"!==a&&(s.left+=l,s.gridX+=l,s.elementClientX+=l),"x"!==a&&(s.top+=d,s.gridY+=d,s.elementClientY+=d),o.dragSort&&e._checkSortOverlap()},function(){C(n,{transform:I(s.left,s.top)}),r._emit("dragMove",i,t)}),e},d.prototype.onScroll=function(t){var e,i,n,r,o=this,s=o.getItem(),a=s._element,l=o.getGrid(),d=l._settings,f=d.dragAxis,u=o._data,h=l._element;return dt.add(ht,s._id,function(){e=a.getBoundingClientRect(),i=u.elementClientX-e.left,n=u.elementClientY-e.top,u.container!==h&&(r=E(u.containingBlock,h),u.containerDiffX=r.left,u.containerDiffY=r.top),"y"!==f&&(u.left+=i,u.gridX=u.left-u.containerDiffX),"x"!==f&&(u.top+=n,u.gridY=u.top-u.containerDiffY),d.dragSort&&o._checkSortOverlap()},function(){C(a,{transform:I(u.left,u.top)}),l._emit("dragScroll",s,t)}),o},d.prototype.onEnd=function(t){var e=this,i=e.getItem(),n=i._element,r=e.getGrid(),o=r._settings,s=e._data,a=i._release;return i._isActive?(e.cancelRafLoop(),o.dragSort&&e._checkSortOverlap("finish"),e.unbindScrollListeners(),a.containerDiffX=s.containerDiffX,a.containerDiffY=s.containerDiffY,e.reset(),x(n,o.itemDraggingClass),r._emit("dragEnd",i,t),e._isMigrating?e.finishMigration():a.start(),e):e.stop()},Z.getSlot=function(t,e,i,n,r,o){var s,a,l,d,f,u=[],h={left:null,top:null,width:i,height:n};for(d=0;d<e.length;d++)if(s=e[d],h.width<=s.width+.001&&h.height<=s.height+.001){h.left=s.left,h.top=s.top;break}for(null===h.left&&(h.left=r?0:t.width,h.top=r?t.height:0,o||(l=!0)),r&&h.top+h.height>t.height&&(h.left>0&&u.push({left:0,top:t.height,width:h.left,height:1/0}),h.left+h.width<t.width&&u.push({left:h.left+h.width,top:t.height,width:t.width-h.left-h.width,height:1/0}),t.height=h.top+h.height),!r&&h.left+h.width>t.width&&(h.top>0&&u.push({left:t.width,top:0,width:1/0,height:h.top}),h.top+h.height<t.height&&u.push({left:t.width,top:h.top+h.height,width:1/0,height:t.height-h.top-h.height}),t.width=h.left+h.width),d=o?0:l?e.length:d;d<e.length;d++)for(a=Z.splitRect(e[d],h),f=0;f<a.length;f++)(s=a[f]).width>.49&&s.height>.49&&(r&&s.top<t.height||!r&&s.left<t.width)&&u.push(s);return u.length&&(u=Z.purgeRects(u).sort(r?Z.sortRectsTopLeft:Z.sortRectsLeftTop)),[h,u]},Z.splitRect=function(t,e){var i=[];return Z.doRectsOverlap(t,e)?(t.left<e.left&&i.push({left:t.left,top:t.top,width:e.left-t.left,height:t.height}),t.left+t.width>e.left+e.width&&i.push({left:e.left+e.width,top:t.top,width:t.left+t.width-(e.left+e.width),height:t.height}),t.top<e.top&&i.push({left:t.left,top:t.top,width:t.width,height:e.top-t.top}),t.top+t.height>e.top+e.height&&i.push({left:t.left,top:e.top+e.height,width:t.width,height:t.top+t.height-(e.top+e.height)}),i):[{left:t.left,top:t.top,width:t.width,height:t.height}]},Z.doRectsOverlap=function(t,e){return!(t.left+t.width<=e.left||e.left+e.width<=t.left||t.top+t.height<=e.top||e.top+e.height<=t.top)},Z.isRectWithinRect=function(t,e){return t.left>=e.left&&t.top>=e.top&&t.left+t.width<=e.left+e.width&&t.top+t.height<=e.top+e.height},Z.purgeRects=function(t){for(var e,i,n,r=t.length;r--;)for(i=t[r],e=t.length;e--;)if(n=t[e],r!==e&&Z.isRectWithinRect(i,n)){t.splice(r,1);break}return t},Z.sortRectsTopLeft=function(t,e){return t.top-e.top||t.left-e.left},Z.sortRectsLeftTop=function(t,e){return t.left-e.left||t.top-e.top},n}); |
{ | ||
"name": "muuri", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Responsive, sortable, filterable and draggable grid layouts.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
265166
0.08%4807
0.1%