Comparing version 0.7.1 to 0.8.0
{ | ||
"printWidth": 100, | ||
"singleQuote": true | ||
} | ||
} |
@@ -6,2 +6,4 @@ Authors ordered by first contribution. | ||
Jason Holland <https://github.com/jholland918> | ||
Aslak Hellesøy <https://github.com/aslakhellesoy> | ||
Aslak Hellesøy <https://github.com/aslakhellesoy> | ||
Makhambet Adiyetov <https://github.com/stat92> | ||
Alexis Rouillard <https://github.com/Alexays> |
/** | ||
* Muuri v0.7.1 | ||
* https://github.com/haltu/muuri | ||
* Copyright (c) 2015-present, Haltu Oy | ||
* Released under the MIT license | ||
* https://github.com/haltu/muuri/blob/master/LICENSE.md | ||
* @license MIT | ||
* | ||
* Muuri Packer | ||
* Copyright (c) 2016-present, Niklas Rämö <inramo@gmail.com> | ||
* @license MIT | ||
* | ||
* Muuri Ticker / Muuri Emitter / Muuri Queue | ||
* Copyright (c) 2018-present, Niklas Rämö <inramo@gmail.com> | ||
* @license MIT | ||
*/ | ||
!function(t,i){if("object"==typeof exports&&"undefined"!=typeof module){var e;try{e=require("hammerjs")}catch(t){}module.exports=i(e)}else t.Muuri=i(t.Hammer)}(this,function(t){"use strict";var i="Muuri",e={},s="layoutEnd";function n(){this._events={},this._queue=[],this._counter=0,this._isDestroyed=!1}n.prototype.on=function(t,i){if(this._isDestroyed)return this;var e=this._events[t];return e||(e=this._events[t]=[]),e.push(i),this},n.prototype.once=function(t,i){if(this._isDestroyed)return this;var e=function(){this.off(t,e),i.apply(null,arguments)}.bind(this);return this.on(t,e)},n.prototype.off=function(t,i){if(this._isDestroyed)return this;var e=this._events[t];if(!e||!e.length)return this;if(!i)return e.length=0,this;for(var s=e.length;s--;)i===e[s]&&e.splice(s,1);return this},n.prototype.emit=function(t,i,e,s){if(this._isDestroyed)return this;var n=this._events[t];if(!n||!n.length)return this;var r,o=this._queue,h=o.length,a=arguments.length-1;for(r=0;r<n.length;r++)o.push(n[r]);for(++this._counter,r=h,h=o.length;r<h;r++)if(0===a?o[r]():1===a?o[r](i):2===a?o[r](i,e):o[r](i,e,s),this._isDestroyed)return this;return--this._counter,this._counter||(o.length=0),this},n.prototype.destroy=function(){if(this._isDestroyed)return this;var t,i=this._events;for(t in this._isDestroyed=!0,this._queue.length=this._counter=0,i)i[t]&&(i[t].length=0,i[t]=void 0);return this};var r=!1,o="transform",h="transform";["","Webkit","Moz","O","ms"].forEach(function(t){if(!r){var i=t?t+"Transform":"transform";void 0!==document.documentElement.style[i]&&(t=t.toLowerCase(),o=t?"-"+t+"-transform":"transform",h=i,r=!0)}});var a="function"==typeof WeakMap?new WeakMap:null;function _(t,i){var e=a&&a.get(t);return e||(e=window.getComputedStyle(t,null),a&&a.set(t,e)),e.getPropertyValue("transform"===i?o:i)}var l=/([A-Z])/g;function d(t){return t.replace(l,"-$1").toLowerCase()}function f(t,i){for(var e in i)t.style["transform"===e?h:e]=i[e]}function u(t){this._element=t,this._animation=null,this._callback=null,this._props=[],this._values=[],this._keyframes=[],this._options={},this._isDestroyed=!1,this._onFinish=this._onFinish.bind(this)}u.prototype.start=function(t,i,e){if(!this._isDestroyed){var s=this._animation,n=this._props,r=this._values,o=e||0,h=!1;if(s){var a,_=0;for(var l in i)if(++_,-1===(a=n.indexOf(l))||i[l]!==r[a]){h=!0;break}h||_===n.length||(h=!0)}if(h&&s.cancel(),this._callback="function"==typeof o.onFinish?o.onFinish:null,!s||h){for(l in n.length=r.length=0,i)n.push(l),r.push(i[l]);var d=this._keyframes;d[0]=t,d[1]=i;var u=this._options;u.duration=o.duration||300,u.easing=o.easing||"ease";var c=this._element;(s=c.animate(d,u)).onfinish=this._onFinish,this._animation=s,f(c,i)}}},u.prototype.stop=function(t){if(!this._isDestroyed&&this._animation){var i,e,s,n=this._element,r=this._props,o=this._values;if(t)f(n,t);else for(s=0;s<r.length;s++)e=_(n,d(i=r[s])),n.style["transform"===i?h:i]=e;this._animation.cancel(),this._animation=this._callback=null,r.length=o.length=0}},u.prototype.isAnimating=function(){return!!this._animation},u.prototype.destroy=function(){this._isDestroyed||(this.stop(),this._element=this._options=this._keyframes=null,this._isDestroyed=!0)},u.prototype._onFinish=function(){var t=this._callback;this._animation=this._callback=null,this._props.length=this._values.length=0,t&&t()};var c=(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,16)}).bind(window);function p(){this._nextTick=null,this._queue=[],this._reads={},this._writes={},this._batch=[],this._batchReads={},this._batchWrites={},this._flush=this._flush.bind(this)}p.prototype.add=function(t,i,e,s){var n=this._queue.indexOf(t);n>-1&&(this._queue[n]=void 0),s?this._queue.unshift(t):this._queue.push(t),this._reads[t]=i,this._writes[t]=e,this._nextTick||(this._nextTick=c(this._flush))},p.prototype.cancel=function(t){var i=this._queue.indexOf(t);i>-1&&(this._queue[i]=void 0,this._reads[t]=void 0,this._writes[t]=void 0)},p.prototype._flush=function(){var t,i,e=this._queue,s=this._reads,n=this._writes,r=this._batch,o=this._batchReads,h=this._batchWrites,a=e.length;for(this._nextTick=null,i=0;i<a;i++)(t=e[i])&&(r.push(t),o[t]=s[t],s[t]=void 0,h[t]=n[t],n[t]=void 0);for(e.length=0,i=0;i<a;i++)o[t=r[i]]&&(o[t](),o[t]=void 0);for(i=0;i<a;i++)h[t=r[i]]&&(h[t](),h[t]=void 0);r.length=0,!this._nextTick&&e.length&&(this._nextTick=c(this._flush))};var m=new p,g="layout",y="visibility",v="move",w="scroll";function D(t){return m.cancel(t+g)}function b(t){return m.cancel(t+y)}function S(t){return m.cancel(t+v)}function A(t){return m.cancel(t+w)}var x=Element.prototype,R=x.matches||x.matchesSelector||x.webkitMatchesSelector||x.mozMatchesSelector||x.msMatchesSelector||x.oMatchesSelector;function C(t,i){return R.call(t,i)}var I="classList"in Element.prototype?function(t,i){t.classList.add(i)}:function(t,i){C(t,"."+i)||(t.className+=" "+i)};function L(t,i,e){var s=t.length,n=Math.max(0,e?s:s-1);return i>n?n:i<0?Math.max(n+i+1,0):i}function E(t,i,e){if(!(t.length<2)){var s=L(t,i),n=L(t,e);s!==n&&t.splice(n,0,t.splice(s,1)[0])}}function M(t,i,e){if(!(t.length<2)){var s,n=L(t,i),r=L(t,e);n!==r&&(s=t[n],t[n]=t[r],t[r]=s)}}var H="cancel",G="finish";function P(t,i){var e;return i>0?function(s){void 0!==e&&(e=window.clearTimeout(e),s===G&&t()),s!==H&&s!==G&&(e=window.setTimeout(function(){e=void 0,t()},i))}:function(i){i!==H&&t()}}function T(t){var i=_(t,"transform");if(!i||"none"===i)return!1;var e=_(t,"display");return"inline"!==e&&"none"!==e}function O(t,i){for(var e=(i?t:t.parentElement)||document;e&&e!==document&&"static"===_(e,"position")&&!T(e);)e=e.parentElement||document;return e}function k(t,i){return parseFloat(_(t,i))||0}var X={},Y={},q={};function B(t,i){var e,s=i||{};return s.left=0,s.top=0,t===document?s:(s.left=window.pageXOffset||0,s.top=window.pageYOffset||0,t.self===window.self?s:(e=t.getBoundingClientRect(),s.left+=e.left,s.top+=e.top,s.left+=k(t,"border-left-width"),s.top+=k(t,"border-top-width"),s))}function N(t,i,e){return q.left=0,q.top=0,t===i?q:e&&(t=O(t,!0))===(i=O(i,!0))?q:(B(t,X),B(i,Y),q.left=Y.left-X.left,q.top=Y.top-X.top,q)}var F={};function z(t){F.x=0,F.y=0;var i=_(t,"transform");if(!i)return F;var e=i.replace("matrix(","").split(",");return F.x=parseFloat(e[4])||0,F.y=parseFloat(e[5])||0,F}function V(t,i){return"translateX("+t+"px) translateY("+i+"px)"}var W=[];function j(t,i,e){var s="number"==typeof e?e:-1;s<0&&(s=t.length-s+1),t.splice.apply(t,W.concat(s,0,i)),W.length=0}var Z="[object Object]",$=Object.prototype.toString;function J(t){return"object"==typeof t&&$.call(t)===Z}var K="classList"in Element.prototype?function(t,i){t.classList.remove(i)}:function(t,i){C(t,"."+i)&&(t.className=(" "+t.className+" ").replace(" "+i+" "," ").trim())},Q=at(),U=0,tt=1,it=2,et=3;function st(e){if(!t)throw new Error("["+i+"] required dependency Hammer is not defined.");null===Q&&(Q=at());var s,n,r=this,o=e._element,h=e.getGrid(),a=h._settings,_="function"==typeof a.dragStartPredicate?a.dragStartPredicate:st.defaultStartPredicate,l=U;this._item=e,this._gridId=h._id,this._hammer=s=new t.Manager(o),this._isDestroyed=!1,this._isMigrating=!1,this._reset(),this._onScroll=this._onScroll.bind(this),this._prepareMove=this._prepareMove.bind(this),this._applyMove=this._applyMove.bind(this),this._prepareScroll=this._prepareScroll.bind(this),this._applyScroll=this._applyScroll.bind(this),this._checkOverlap=this._checkOverlap.bind(this),this._forceResolveStartPredicate=function(t){this._isDestroyed||l!==tt||(l=it,this._onStart(t))},this._checkOverlapDebounce=P(this._checkOverlap,a.dragSortInterval),s.add(new t.Pan({event:"drag",pointers:1,threshold:0,direction:t.DIRECTION_ALL})),s.add(new t.Press({event:"draginit",pointers:1,threshold:1e3,time:0})),J(a.dragHammerSettings)&&s.set(a.dragHammerSettings),s.on("draginit dragstart dragmove",function(t){l===U&&(l=tt),l===tt?!0===(n=_(r._item,t))?(l=it,r._onStart(t)):!1===n&&(l=et):l===it&&r._isActive&&r._onMove(t)}).on("dragend dragcancel draginitup",function(t){var i=l===it;_(r._item,t),l=U,i&&r._isActive&&r._onEnd(t)}),o.addEventListener("dragstart",nt,!1)}function nt(t){t.preventDefault&&t.preventDefault()}function rt(t,i){return t.left+t.width<=i.left||i.left+i.width<=t.left||t.top+t.height<=i.top||i.top+i.height<=t.top?0:(Math.min(t.left+t.width,i.left+i.width)-Math.max(t.left,i.left))*(Math.min(t.top+t.height,i.top+i.height)-Math.max(t.top,i.top))/(Math.min(t.width,i.width)*Math.min(t.height,i.height))*100}function ot(t,i){var e=i||[],s=t.parentNode;if(Q){if("fixed"===_(t,"position"))return e;for(;s&&s!==document&&s!==document.documentElement;)ht(s)&&e.push(s),s="fixed"===_(s,"position")?null:s.parentNode;return null!==s&&e.push(window),e}for(;s&&s!==document;)"fixed"!==_(t,"position")||T(s)?(ht(s)&&e.push(s),t=s,s=s.parentNode):s=s.parentNode;return e[e.length-1]===document.documentElement?e[e.length-1]=window:e.push(window),e}function ht(t){var i=_(t,"overflow");return"auto"===i||"scroll"===i||("auto"===(i=_(t,"overflow-x"))||"scroll"===i||("auto"===(i=_(t,"overflow-y"))||"scroll"===i))}function at(){if(!r)return!0;if(!document.body)return null;var t=[0,1].map(function(t,i){return(t=document.createElement("div")).style.position=i?"fixed":"absolute",t.style.display="block",t.style.visibility="hidden",t.style.left=i?"0px":"1px",t.style[h]="none",t}),i=document.body.appendChild(t[0]),e=i.appendChild(t[1]),s=e.getBoundingClientRect().left;i.style[h]="scale(1)";var n=s===e.getBoundingClientRect().left;return document.body.removeChild(i),n}function _t(){this._queue=[],this._isDestroyed=!1}function lt(t){this._item=t,this._isActive=!1,this._isDestroyed=!1,this._isInterrupted=!1,this._currentStyles={},this._targetStyles={},this._currentLeft=0,this._currentTop=0,this._offsetLeft=0,this._offsetTop=0,this._skipNextAnimation=!1,this._animateOptions={onFinish:this._finish.bind(this)},this._queue=new _t,this._setupAnimation=this._setupAnimation.bind(this),this._startAnimation=this._startAnimation.bind(this)}st.defaultStartPredicate=function(t,i,e){var s=t._drag,n=s._startPredicateData||s._setupStartPredicate(e);if(!i.isFinal)return!(!n.handleElement&&(n.handleElement=s._getStartPredicateHandle(i),!n.handleElement))&&(n.delay&&(n.event=i,n.delayTimer||(n.delayTimer=window.setTimeout(function(){n.delay=0,s._resolveStartPredicate(n.event)&&(s._forceResolveStartPredicate(n.event),s._resetStartPredicate())},n.delay))),s._resolveStartPredicate(i));s._finishStartPredicate(i)},st.defaultSortPredicate=function(){var t={},i={},e={},s=[];return function(n,r){var o=n._drag,h=o._getGrid(),a=r&&"number"==typeof r.threshold?r.threshold:50,_=r&&"swap"===r.action?"swap":"move";t.width=n._width,t.height=n._height,t.left=o._elementClientX,t.top=o._elementClientY;var l=function(e,n,r){var o,h,a,_,l=null,d=n._settings.dragSort,f=-1;if(!0===d?(s[0]=n,h=s):h=d.call(n,e),!Array.isArray(h))return l;for(_=0;_<h.length;_++)(a=h[_])._isDestroyed||(a._updateBoundingRect(),i.width=a._width,i.height=a._height,i.left=a._left,i.top=a._top,(o=rt(t,i))>r&&o>f&&(f=o,l=a));return s.length=0,l}(n,h,a);if(!l)return!1;var d,f,u,c,p,m=0,g=0,y=-1;for(l===h?(t.left=o._gridX+n._marginLeft,t.top=o._gridY+n._marginTop):(l._updateBorders(1,0,1,0),m=l._left+l._borderLeft,g=l._top+l._borderTop),p=0;p<l._items.length;p++)(u=l._items[p])._isActive&&u!==n&&(f=!0,i.width=u._width,i.height=u._height,i.left=u._left+u._marginLeft+m,i.top=u._top+u._marginTop+g,(c=rt(t,i))>y&&(d=p,y=c));return y<a&&n.getGrid()!==l&&(d=f?-1:0,y=1/0),y>=a&&(e.grid=l,e.index=d,e.action=_,e)}}(),st.prototype.stop=function(){var t=this._item,i=t._element,e=this._getGrid();return this._isActive?this._isMigrating?(this._finishMigration(),this):(S(t._id),A(t._id),this._unbindScrollListeners(),this._checkOverlapDebounce("cancel"),i.parentNode!==e._element&&(e._element.appendChild(i),i.style[h]=V(this._gridX,this._gridY)),K(i,e._settings.itemDraggingClass),this._reset(),this):this},st.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(),this._hammer.destroy(),this._item._element.removeEventListener("dragstart",nt,!1),this._isDestroyed=!0,this)},st.prototype._getGrid=function(){return e[this._gridId]||null},st.prototype._reset=function(){this._isActive=!1,this._container=null,this._containingBlock=null,this._lastEvent=null,this._lastScrollEvent=null,this._scrollers=[],this._left=0,this._top=0,this._gridX=0,this._gridY=0,this._elementClientX=0,this._elementClientY=0,this._containerDiffX=0,this._containerDiffY=0},st.prototype._bindScrollListeners=function(){var t,i,e=this._getGrid()._element,s=this._container,n=this._scrollers;if(n.length=0,ot(this._item._element,n),s!==e)for(ot(e,t=[]),t.push(e),i=0;i<t.length;i++)n.indexOf(t[i])<0&&n.push(t[i]);for(i=0;i<n.length;i++)n[i].addEventListener("scroll",this._onScroll)},st.prototype._unbindScrollListeners=function(){var t,i=this._scrollers;for(t=0;t<i.length;t++)i[t].removeEventListener("scroll",this._onScroll);i.length=0},st.prototype._setupStartPredicate=function(t){var i=t||this._getGrid()._settings.dragStartPredicate||0;return this._startPredicateData={distance:Math.abs(i.distance)||0,delay:Math.max(i.delay,0)||0,handle:"string"==typeof i.handle&&i.handle}},st.prototype._getStartPredicateHandle=function(t){var i=this._startPredicateData,e=this._item._element,s=e;if(!i.handle)return s;for(s=(t.changedPointers[0]||0).target;s&&!C(s,i.handle);)s=s!==e?s.parentElement:null;return s||null},st.prototype._resolveStartPredicate=function(t){var i,e,s,n,r,o=this._startPredicateData,h=t.changedPointers[0],a=h&&h.pageX||0,_=h&&h.pageY||0;if(!(t.distance<o.distance||o.delay))return e=(i=o.handleElement.getBoundingClientRect()).left+(window.pageXOffset||0),s=i.top+(window.pageYOffset||0),n=i.width,r=i.height,this._resetStartPredicate(),n&&r&&a>=e&&a<e+n&&_>=s&&_<s+r},st.prototype._finishStartPredicate=function(t){var i=this._item._element;this._resetStartPredicate(),function(t){return Math.abs(t.deltaX)<2&&Math.abs(t.deltaY)<2&&t.deltaTime<200}(t)&&function(t){if("a"!==t.tagName.toLowerCase())return;var i=t.getAttribute("href");if(!i)return;var e=t.getAttribute("target");e&&"_self"!==e?window.open(i,e):window.location.href=i}(i)},st.prototype._resetStartPredicate=function(){var t=this._startPredicateData;t&&(t.delayTimer&&(t.delayTimer=window.clearTimeout(t.delayTimer)),this._startPredicateData=null)},st.prototype._checkOverlap=function(){if(this._isActive){var t,i,e,s,n,r,o,h=this._item,a=this._getGrid()._settings;(t="function"==typeof a.dragSortPredicate?a.dragSortPredicate(h,this._lastEvent):st.defaultSortPredicate(h,a.dragSortPredicate))&&"number"==typeof t.index&&(o=(i=h.getGrid())!==(s=t.grid||i),e=i._items.indexOf(h),n=L(s._items,t.index,o),r="swap"===t.action?"swap":"move",o?(i._hasListeners("beforeSend")&&i._emit("beforeSend",{item:h,fromGrid:i,fromIndex:e,toGrid:s,toIndex:n}),s._hasListeners("beforeReceive")&&s._emit("beforeReceive",{item:h,fromGrid:i,fromIndex:e,toGrid:s,toIndex:n}),h._gridId=s._id,this._isMigrating=h._gridId!==this._gridId,i._items.splice(e,1),j(s._items,h,n),h._sortData=null,i._hasListeners("send")&&i._emit("send",{item:h,fromGrid:i,fromIndex:e,toGrid:s,toIndex:n}),s._hasListeners("receive")&&s._emit("receive",{item:h,fromGrid:i,fromIndex:e,toGrid:s,toIndex:n}),i.layout(),s.layout()):e!==n&&(("swap"===r?M:E)(i._items,e,n),i._hasListeners("move")&&i._emit("move",{item:h,fromIndex:e,toIndex:n,action:r}),i.layout()))}},st.prototype._finishMigration=function(){var t,i,e=this._item,s=e._release,n=e._element,r=e._isActive,o=e.getGrid(),a=o._element,_=o._settings,l=_.dragContainer||a,d=this._getGrid()._settings,u=n.parentNode;this._isMigrating=!1,this.destroy(),K(n,d.itemClass),K(n,d.itemVisibleClass),K(n,d.itemHiddenClass),I(n,_.itemClass),I(n,r?_.itemVisibleClass:_.itemHiddenClass),l!==u&&(l.appendChild(n),i=N(u,l,!0),(t=z(n)).x-=i.left,t.y-=i.top),e._refreshDimensions(),e._refreshSortData(),i=N(l,a,!0),s._containerDiffX=i.left,s._containerDiffY=i.top,e._drag=_.dragEnabled?new st(e):null,l!==u&&(n.style[h]=V(t.x,t.y)),e._child.removeAttribute("style"),f(e._child,r?_.visibleStyles:_.hiddenStyles),s.start()},st.prototype._onStart=function(t){var i=this._item;if(i._isActive){var e,s=i._element,n=this._getGrid(),r=n._settings,o=i._release,a=i._migrate,_=n._element,l=r.dragContainer||_,d=O(l,!0),f=z(s),u=f.x,c=f.y,p=s.getBoundingClientRect(),m=l!==_;m&&(e=N(d,_)),i.isPositioning()&&i._layout.stop(!0,{transform:V(u,c)}),a._isActive&&(u-=a._containerDiffX,c-=a._containerDiffY,a.stop(!0,{transform:V(u,c)})),i.isReleasing()&&o._reset(),this._isActive=!0,this._lastEvent=t,this._container=l,this._containingBlock=d,this._elementClientX=p.left,this._elementClientY=p.top,this._left=this._gridX=u,this._top=this._gridY=c,n._emit("dragInit",i,t),m&&(this._containerDiffX=e.left,this._containerDiffY=e.top,s.parentNode===l?(this._gridX=u-this._containerDiffX,this._gridY=c-this._containerDiffY):(this._left=u+this._containerDiffX,this._top=c+this._containerDiffY,l.appendChild(s),s.style[h]=V(this._left,this._top))),I(s,r.itemDraggingClass),this._bindScrollListeners(),n._emit("dragStart",i,t)}},st.prototype._onMove=function(t){var i=this._item;if(i._isActive){var e,s,n,r=this._getGrid()._settings.dragAxis,o=t.deltaX-this._lastEvent.deltaX,h=t.deltaY-this._lastEvent.deltaY;this._lastEvent=t,"y"!==r&&(this._left+=o,this._gridX+=o,this._elementClientX+=o),"x"!==r&&(this._top+=h,this._gridY+=h,this._elementClientY+=h),e=i._id,s=this._prepareMove,n=this._applyMove,m.add(e+v,s,n,!0)}else this.stop()},st.prototype._prepareMove=function(){this._item._isActive&&this._getGrid()._settings.dragSort&&this._checkOverlapDebounce()},st.prototype._applyMove=function(){var t=this._item;t._isActive&&(t._element.style[h]=V(this._left,this._top),this._getGrid()._emit("dragMove",t,this._lastEvent))},st.prototype._onScroll=function(t){var i,e,s,n=this._item;n._isActive?(this._lastScrollEvent=t,i=n._id,e=this._prepareScroll,s=this._applyScroll,m.add(i+w,e,s,!0)):this.stop()},st.prototype._prepareScroll=function(){var t=this._item;if(t._isActive){var i,e=t._element,s=this._getGrid(),n=s._settings,r=n.dragAxis,o=s._element,h=e.getBoundingClientRect(),a=this._elementClientX-h.left,_=this._elementClientY-h.top;this._container!==o&&(i=N(this._containingBlock,o),this._containerDiffX=i.left,this._containerDiffY=i.top),"y"!==r&&(this._left+=a,this._gridX=this._left-this._containerDiffX),"x"!==r&&(this._top+=_,this._gridY=this._top-this._containerDiffY),n.dragSort&&this._checkOverlapDebounce()}},st.prototype._applyScroll=function(){var t=this._item;t._isActive&&(t._element.style[h]=V(this._left,this._top),this._getGrid()._emit("dragScroll",t,this._lastScrollEvent))},st.prototype._onEnd=function(t){var i=this._item,e=i._element,s=this._getGrid(),n=s._settings,r=i._release;i._isActive?(S(i._id),A(i._id),n.dragSort&&this._checkOverlapDebounce("finish"),this._unbindScrollListeners(),r._containerDiffX=this._containerDiffX,r._containerDiffY=this._containerDiffY,this._reset(),K(e,n.itemDraggingClass),s._emit("dragEnd",i,t),this._isMigrating?this._finishMigration():r.start()):this.stop()},_t.prototype.add=function(t){return this._isDestroyed?this:(this._queue.push(t),this)},_t.prototype.flush=function(t,i){if(this._isDestroyed)return this;var e,s=this._queue,n=s.length;if(!n)return this;var r=1===n,o=r?s[0]:s.slice(0);if(s.length=0,r)return o(t,i),this;for(e=0;e<n&&(o[e](t,i),!this._isDestroyed);e++);return this},_t.prototype.destroy=function(){return this._isDestroyed?this:(this._isDestroyed=!0,this._queue.length=0,this)},lt.prototype.start=function(t,i){if(!this._isDestroyed){var e,s,n,r,o=this._item,h=o._element,a=o._release,_=o.getGrid()._settings,l=this._isActive,d=a._isActive&&!1===a._isPositioningStarted,u=d?_.dragReleaseDuration:_.layoutDuration,c=d?_.dragReleaseEasing:_.layoutEasing,p=!t&&!this._skipNextAnimation&&u>0;return l&&this._queue.flush(!0,o),d&&(a._isPositioningStarted=!0),"function"==typeof i&&this._queue.add(i),p?(this._isActive=!0,this._animateOptions.easing=c,this._animateOptions.duration=u,this._isInterrupted=l,s=o._id,n=this._setupAnimation,r=this._startAnimation,m.add(s+g,n,r),this):(this._updateOffsets(),this._updateTargetStyles(),l&&D(o._id),e=o._animate.isAnimating(),this.stop(!1,this._targetStyles),!e&&f(h,this._targetStyles),this._skipNextAnimation=!1,this._finish())}},lt.prototype.stop=function(t,i){if(this._isDestroyed||!this._isActive)return this;var e=this._item;return D(e._id),e._animate.stop(i),K(e._element,e.getGrid()._settings.itemPositioningClass),this._isActive=!1,t&&this._queue.flush(!0,e),this},lt.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(!0,{}),this._queue.destroy(),this._item=this._currentStyles=this._targetStyles=this._animateOptions=null,this._isDestroyed=!0,this)},lt.prototype._updateOffsets=function(){if(!this._isDestroyed){var t=this._item,i=t._migrate,e=t._release;this._offsetLeft=e._isActive?e._containerDiffX:i._isActive?i._containerDiffX:0,this._offsetTop=e._isActive?e._containerDiffY:i._isActive?i._containerDiffY:0}},lt.prototype._updateTargetStyles=function(){if(!this._isDestroyed){var t=this._item;this._targetStyles.transform=V(t._left+this._offsetLeft,t._top+this._offsetTop)}},lt.prototype._finish=function(){if(!this._isDestroyed){var t=this._item,i=t._migrate,e=t._release;this._isActive&&(this._isActive=!1,K(t._element,t.getGrid()._settings.itemPositioningClass)),e._isActive&&e.stop(),i._isActive&&i.stop(),this._queue.flush(!1,t)}},lt.prototype._setupAnimation=function(){var t=z(this._item._element);this._currentLeft=t.x,this._currentTop=t.y},lt.prototype._startAnimation=function(){var t=this._item,i=t._element,e=t.getGrid()._settings;if(this._updateOffsets(),this._updateTargetStyles(),t._left===this._currentLeft-this._offsetLeft&&t._top===this._currentTop-this._offsetTop)return this._isInterrupted&&this.stop(!1,this._targetStyles),this._isActive=!1,void this._finish();!this._isInterrupted&&I(i,e.itemPositioningClass),this._currentStyles.transform=V(this._currentLeft,this._currentTop),t._animate.start(this._currentStyles,this._targetStyles,this._animateOptions)};var dt={};function ft(t){this._item=t,this._isActive=!1,this._isDestroyed=!1,this._container=!1,this._containerDiffX=0,this._containerDiffY=0}ft.prototype.start=function(t,i,e){if(this._isDestroyed)return this;var s,n,r,o,a,_,l,d,u=this._item,c=u._element,p=u.isVisible(),m=u.getGrid(),g=m._settings,y=t._settings,v=t._element,w=t._items,D=m._items.indexOf(u),b=e||document.body;if("number"==typeof i)s=L(w,i,!0);else{if(!(n=t._getItem(i)))return this;s=w.indexOf(n)}return(u.isPositioning()||this._isActive||u.isReleasing())&&(l=(_=z(c)).x,d=_.y),u.isPositioning()&&u._layout.stop(!0,{transform:V(l,d)}),this._isActive&&(l-=this._containerDiffX,d-=this._containerDiffY,this.stop(!0,{transform:V(l,d)})),u.isReleasing()&&(l-=u._release._containerDiffX,d-=u._release._containerDiffY,u._release.stop(!0,{transform:V(l,d)})),u._visibility._stopAnimation(),u._drag&&u._drag.destroy(),u._visibility._queue.flush(!0,u),m._hasListeners("beforeSend")&&m._emit("beforeSend",{item:u,fromGrid:m,fromIndex:D,toGrid:t,toIndex:s}),t._hasListeners("beforeReceive")&&t._emit("beforeReceive",{item:u,fromGrid:m,fromIndex:D,toGrid:t,toIndex:s}),K(c,g.itemClass),K(c,g.itemVisibleClass),K(c,g.itemHiddenClass),I(c,y.itemClass),I(c,p?y.itemVisibleClass:y.itemHiddenClass),m._items.splice(D,1),j(w,u,s),u._gridId=t._id,b!==(r=c.parentNode)&&(b.appendChild(c),o=N(b,r,!0),_||(l=(_=z(c)).x,d=_.y),c.style[h]=V(l+o.left,d+o.top)),u._child.removeAttribute("style"),f(u._child,p?y.visibleStyles:y.hiddenStyles),c.style.display=p?"block":"hidden",a=N(b,v,!0),u._refreshDimensions(),u._refreshSortData(),u._drag=y.dragEnabled?new st(u):null,this._isActive=!0,this._container=b,this._containerDiffX=a.left,this._containerDiffY=a.top,m._hasListeners("send")&&m._emit("send",{item:u,fromGrid:m,fromIndex:D,toGrid:t,toIndex:s}),t._hasListeners("receive")&&t._emit("receive",{item:u,fromGrid:m,fromIndex:D,toGrid:t,toIndex:s}),this},ft.prototype.stop=function(t,i){if(this._isDestroyed||!this._isActive)return this;var e,s=this._item,n=s._element,r=s.getGrid()._element;return this._container!==r&&(i||(t?(e=z(n),dt.transform=V(e.x-this._containerDiffX,e.y-this._containerDiffY)):dt.transform=V(s._left,s._top),i=dt),r.appendChild(n),f(n,i)),this._isActive=!1,this._container=null,this._containerDiffX=0,this._containerDiffY=0,this},ft.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(!0),this._item=null,this._isDestroyed=!0,this)};var ut={};function ct(t){this._item=t,this._isActive=!1,this._isDestroyed=!1,this._isPositioningStarted=!1,this._containerDiffX=0,this._containerDiffY=0}function pt(t){var i=t._isActive,e=t._element,s=t.getGrid()._settings;this._item=t,this._isDestroyed=!1,this._isHidden=!i,this._isHiding=!1,this._isShowing=!1,this._queue=new _t,this._finishShow=this._finishShow.bind(this),this._finishHide=this._finishHide.bind(this),e.style.display=i?"block":"none",I(e,i?s.itemVisibleClass:s.itemHiddenClass),f(t._child,i?s.visibleStyles:s.hiddenStyles)}ct.prototype.start=function(){if(this._isDestroyed||this._isActive)return this;var t=this._item,i=t.getGrid();return this._isActive=!0,I(t._element,i._settings.itemReleasingClass),i._emit("dragReleaseStart",t),t._layout.start(!1),this},ct.prototype.stop=function(t,i){if(this._isDestroyed||!this._isActive)return this;var e,s=this._item,n=s._element,r=s.getGrid(),o=r._element;return this._reset(),n.parentNode!==o&&(i||(t?(e=z(n),ut.transform=V(e.x-this._containerDiffX,e.y-this._containerDiffY)):ut.transform=V(s._left,s._top),i=ut),o.appendChild(n),f(n,i)),t||r._emit("dragReleaseEnd",s),this},ct.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(!0),this._item=null,this._isDestroyed=!0,this)},ct.prototype._reset=function(){if(!this._isDestroyed){var t=this._item;this._isActive=!1,this._isPositioningStarted=!1,this._containerDiffX=0,this._containerDiffY=0,K(t._element,t.getGrid()._settings.itemReleasingClass)}},pt.prototype.show=function(t,i){if(this._isDestroyed)return this;var e=this._item,s=e._element,n=this._queue,r="function"==typeof i?i:null,o=e.getGrid()._settings;return this._isShowing||this._isHidden?this._isShowing&&!t?(r&&n.add(r),this):(this._isShowing||(n.flush(!0,e),K(s,o.itemHiddenClass),I(s,o.itemVisibleClass),this._isHiding||(s.style.display="block")),r&&n.add(r),e._isActive=this._isShowing=!0,this._isHiding=this._isHidden=!1,this._startAnimation(!0,t,this._finishShow),this):(r&&r(!1,e),this)},pt.prototype.hide=function(t,i){if(this._isDestroyed)return this;var e=this._item,s=e._element,n=this._queue,r="function"==typeof i?i:null,o=e.getGrid()._settings;return!this._isHiding&&this._isHidden?(r&&r(!1,e),this):this._isHiding&&!t?(r&&n.add(r),this):(this._isHiding||(n.flush(!0,e),I(s,o.itemHiddenClass),K(s,o.itemVisibleClass)),r&&n.add(r),this._isHidden=this._isHiding=!0,e._isActive=this._isShowing=!1,this._startAnimation(!1,t,this._finishHide),this)},pt.prototype.destroy=function(){if(this._isDestroyed)return this;var t=this._item,i=t._element,e=t.getGrid(),s=this._queue,n=e._settings;return this._stopAnimation({}),s.flush(!0,t).destroy(),K(i,n.itemVisibleClass),K(i,n.itemHiddenClass),this._item=null,this._isHiding=this._isShowing=!1,this._isDestroyed=this._isHidden=!0,this},pt.prototype._startAnimation=function(t,i,e){if(!this._isDestroyed){var s,n=this._item,r=n.getGrid()._settings,o=t?r.visibleStyles:r.hiddenStyles,h=parseInt(t?r.showDuration:r.hideDuration)||0,a=(t?r.showEasing:r.hideEasing)||"ease",l=i||h<=0;if(o){if(b(n._id),l)return n._animateChild.isAnimating()?n._animateChild.stop(o):f(n._child,o),void(e&&e());var u,c,p;u=n._id,c=function(){s=function(t,i){var e={};for(var s in i)e[s]=_(t,d(s));return e}(n._child,o)},p=function(){n._animateChild.start(s,o,{duration:h,easing:a,onFinish:e})},m.add(u+y,c,p)}else e&&e()}},pt.prototype._stopAnimation=function(t){if(!this._isDestroyed){var i=this._item;b(i._id),i._animateChild.stop(t)}},pt.prototype._finishShow=function(){this._isHidden||(this._isShowing=!1,this._queue.flush(!1,this._item))};var mt={};pt.prototype._finishHide=function(){if(this._isHidden){var t=this._item;this._isHiding=!1,mt.transform=V(0,0),t._layout.stop(!0,mt),t._element.style.display="none",this._queue.flush(!1,t)}};var gt,yt,vt,wt,Dt=0;function bt(){return++Dt}function St(t,i,e){var s=t._settings;this._id=bt(),this._gridId=t._id,this._isDestroyed=!1,this._left=0,this._top=0,this._element=i,this._child=i.children[0],i.parentNode!==t._element&&t._element.appendChild(i),I(i,s.itemClass),"boolean"!=typeof e&&(e="none"!==_(i,"display")),this._isActive=e,i.style.left="0",i.style.top="0",i.style[h]=V(0,0),this._animate=new u(i),this._animateChild=new u(this._child),this._visibility=new pt(this),this._layout=new lt(this),this._migrate=new ft(this),this._release=new ct(this),this._drag=s.dragEnabled?new st(this):null,this._refreshDimensions(),this._refreshSortData()}function At(){this._slots=[],this._slotSizes=[],this._freeSlots=[],this._newSlots=[],this._rectItem={},this._rectStore=[],this._rectId=0,this._layout={slots:null,setWidth:!1,setHeight:!1,width:!1,height:!1},this._sortRectsLeftTop=this._sortRectsLeftTop.bind(this),this._sortRectsTopLeft=this._sortRectsTopLeft.bind(this)}St.prototype.getGrid=function(){return e[this._gridId]},St.prototype.getElement=function(){return this._element},St.prototype.getWidth=function(){return this._width},St.prototype.getHeight=function(){return this._height},St.prototype.getMargin=function(){return{left:this._marginLeft,right:this._marginRight,top:this._marginTop,bottom:this._marginBottom}},St.prototype.getPosition=function(){return{left:this._left,top:this._top}},St.prototype.isActive=function(){return this._isActive},St.prototype.isVisible=function(){return!!this._visibility&&!this._visibility._isHidden},St.prototype.isShowing=function(){return!(!this._visibility||!this._visibility._isShowing)},St.prototype.isHiding=function(){return!(!this._visibility||!this._visibility._isHiding)},St.prototype.isPositioning=function(){return!(!this._layout||!this._layout._isActive)},St.prototype.isDragging=function(){return!(!this._drag||!this._drag._isActive)},St.prototype.isReleasing=function(){return!(!this._release||!this._release._isActive)},St.prototype.isDestroyed=function(){return this._isDestroyed},St.prototype._refreshDimensions=function(){if(!this._isDestroyed&&!this._visibility._isHidden){var t=this._element,i=t.getBoundingClientRect();this._width=i.width,this._height=i.height,this._marginLeft=Math.max(0,k(t,"margin-left")),this._marginRight=Math.max(0,k(t,"margin-right")),this._marginTop=Math.max(0,k(t,"margin-top")),this._marginBottom=Math.max(0,k(t,"margin-bottom"))}},St.prototype._refreshSortData=function(){if(!this._isDestroyed){var t,i=this._sortData={},e=this.getGrid()._settings.sortData;for(t in e)i[t]=e[t](this,this._element)}},St.prototype._destroy=function(t){if(!this._isDestroyed){var i=this._element,e=this.getGrid(),s=e._settings,n=e._items.indexOf(this);this._release.destroy(),this._migrate.destroy(),this._layout.destroy(),this._visibility.destroy(),this._animate.destroy(),this._animateChild.destroy(),this._drag&&this._drag.destroy(),i.removeAttribute("style"),this._child.removeAttribute("style"),K(i,s.itemClass),n>-1&&e._items.splice(n,1),t&&i.parentNode.removeChild(i),this._isActive=!1,this._isDestroyed=!0}},At.prototype.getLayout=function(t,i,e,s,n){var r,o=this._layout,h=!(!n||!n.fillGaps),a=!(!n||!n.horizontal),_=!(!n||!n.alignRight),l=!(!n||!n.alignBottom),d=!(!n||!n.rounding),f=this._slotSizes;if(o.slots=s||this._slots,o.width=a?0:d?Math.round(i):i,o.height=a?d?Math.round(e):e:0,o.setWidth=a,o.setHeight=!a,o.slots.length=0,f.length=0,!t.length)return o;for(r=0;r<t.length;r++)this._addSlot(t[r],a,h,d,_||l);if(_)for(r=0;r<o.slots.length;r+=2)o.slots[r]=o.width-(o.slots[r]+f[r]);if(l)for(r=1;r<o.slots.length;r+=2)o.slots[r]=o.height-(o.slots[r]+f[r]);return f.length=0,this._freeSlots.length=0,this._newSlots.length=0,this._rectId=0,o},At.prototype._addSlot=(gt={},function(t,i,e,s,n){var r,o,h,a,_,l,d=this._layout,f=this._freeSlots,u=this._newSlots;for(u.length=0,gt.left=null,gt.top=null,gt.width=t._width+t._marginLeft+t._marginRight,gt.height=t._height+t._marginTop+t._marginBottom,s&&(gt.width=Math.round(gt.width),gt.height=Math.round(gt.height)),_=0;_<f.length;_++)if((o=f[_])&&(r=this._getRect(o),gt.width<=r.width+.001&>.height<=r.height+.001)){gt.left=r.left,gt.top=r.top;break}for(null===gt.left&&(gt.left=i?d.width:0,gt.top=i?0:d.height,e||(a=!0)),!i&>.top+gt.height>d.height&&(gt.left>0&&u.push(this._addRect(0,d.height,gt.left,1/0)),gt.left+gt.width<d.width&&u.push(this._addRect(gt.left+gt.width,d.height,d.width-gt.left-gt.width,1/0)),d.height=gt.top+gt.height),i&>.left+gt.width>d.width&&(gt.top>0&&u.push(this._addRect(d.width,0,1/0,gt.top)),gt.top+gt.height<d.height&&u.push(this._addRect(d.width,gt.top+gt.height,1/0,d.height-gt.top-gt.height)),d.width=gt.left+gt.width),_=e?0:a?f.length:_;_<f.length;_++)if(o=f[_])for(r=this._getRect(o),h=this._splitRect(r,gt),l=0;l<h.length;l++)o=h[l],(r=this._getRect(o)).width>.49&&r.height>.49&&(!i&&r.top<d.height||i&&r.left<d.width)&&u.push(o);u.length&&this._purgeRects(u).sort(i?this._sortRectsLeftTop:this._sortRectsTopLeft),i?d.width=Math.max(d.width,gt.left+gt.width):d.height=Math.max(d.height,gt.top+gt.height),d.slots.push(gt.left,gt.top),n&&this._slotSizes.push(gt.width,gt.height),this._freeSlots=u,this._newSlots=f}),At.prototype._addRect=function(t,i,e,s){var n=++this._rectId,r=this._rectStore;return r[n]=t||0,r[++this._rectId]=i||0,r[++this._rectId]=e||0,r[++this._rectId]=s||0,n},At.prototype._getRect=function(t,i){var e=i||this._rectItem,s=this._rectStore;return e.left=s[t]||0,e.top=s[++t]||0,e.width=s[++t]||0,e.height=s[++t]||0,e},At.prototype._splitRect=(yt=[],function(t,i){return yt.length=0,this._doRectsOverlap(t,i)?(t.left<i.left&&yt.push(this._addRect(t.left,t.top,i.left-t.left,t.height)),t.left+t.width>i.left+i.width&&yt.push(this._addRect(i.left+i.width,t.top,t.left+t.width-(i.left+i.width),t.height)),t.top<i.top&&yt.push(this._addRect(t.left,t.top,t.width,i.top-t.top)),t.top+t.height>i.top+i.height&&yt.push(this._addRect(t.left,i.top+i.height,t.width,t.top+t.height-(i.top+i.height))),yt):(yt.push(this._addRect(t.left,t.top,t.width,t.height)),yt)}),At.prototype._doRectsOverlap=function(t,i){return!(t.left+t.width<=i.left||i.left+i.width<=t.left||t.top+t.height<=i.top||i.top+i.height<=t.top)},At.prototype._isRectWithinRect=function(t,i){return t.left>=i.left&&t.top>=i.top&&t.left+t.width<=i.left+i.width&&t.top+t.height<=i.top+i.height},At.prototype._purgeRects=(vt={},wt={},function(t){for(var i,e=t.length;e--;)if(i=t.length,t[e])for(this._getRect(t[e],vt);i--;)if(t[i]&&e!==i&&this._isRectWithinRect(vt,this._getRect(t[i],wt))){t[e]=0;break}return t}),At.prototype._sortRectsTopLeft=function(){var t={},i={};return function(e,s){return this._getRect(e,t),this._getRect(s,i),t.top<i.top?-1:t.top>i.top?1:t.left<i.left?-1:t.left>i.left?1:0}}(),At.prototype._sortRectsLeftTop=function(){var t={},i={};return function(e,s){return this._getRect(e,t),this._getRect(s,i),t.left<i.left?-1:t.left>i.left?1:t.top<i.top?-1:t.top>i.top?1:0}}();var xt="[object HTMLCollection]",Rt="[object NodeList]";function Ct(t){var i=Object.prototype.toString.call(t);return i===xt||i===Rt}function It(t){return Ct(t)?Array.prototype.slice.call(t):Array.prototype.concat(t)}var Lt=new At,Et=function(){};function Mt(t,i){var s,r,o,h=this;if(t=this._element="string"==typeof t?document.querySelector(t):t,!document.body.contains(t))throw new Error("Container element must be an existing DOM element");"function"!=typeof(s=this._settings=function(t,i){var e=Ht({},t);i&&(e=Ht(e,i));return e.visibleStyles=(i||0).visibleStyles||(t||0).visibleStyles,e.hiddenStyles=(i||0).hiddenStyles||(t||0).hiddenStyles,e}(Mt.defaultOptions,i)).dragSort&&(s.dragSort=!!s.dragSort),this._id=bt(),e[this._id]=h,this._isDestroyed=!1,this._layout={id:0,items:[],slots:[],setWidth:!1,setHeight:!1,width:0,height:0},this._emitter=new n,I(t,s.containerClass),this._items=[],"string"==typeof(r=s.items)?It(t.children).forEach(function(t){("*"===r||C(t,r))&&h._items.push(new St(h,t))}):(Array.isArray(r)||Ct(r))&&(this._items=It(r).map(function(t){return new St(h,t)})),"number"!=typeof(o=s.layoutOnResize)&&(o=!0===o?0:-1),o>=0&&window.addEventListener("resize",h._resizeHandler=P(function(){h.refreshItems().layout()},o)),s.layoutOnInit&&this.layout(!0)}function Ht(t,i){var e,s,n,r=Object.keys(i),o=r.length;for(n=0;n<o;n++)e=J(i[s=r[n]]),J(t[s])&&e?t[s]=Ht(Ht({},t[s]),i[s]):e?t[s]=Ht({},i[s]):Array.isArray(i[s])?t[s]=i[s].slice(0):t[s]=i[s];return t}return Mt.Item=St,Mt.ItemLayout=lt,Mt.ItemVisibility=pt,Mt.ItemRelease=ct,Mt.ItemMigrate=ft,Mt.ItemAnimate=u,Mt.ItemDrag=st,Mt.Emitter=n,Mt.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"},Mt.prototype.on=function(t,i){return this._emitter.on(t,i),this},Mt.prototype.once=function(t,i){return this._emitter.once(t,i),this},Mt.prototype.off=function(t,i){return this._emitter.off(t,i),this},Mt.prototype.getElement=function(){return this._element},Mt.prototype.getItems=function(t){if(this._isDestroyed||!t&&0!==t)return this._items.slice(0);var i,e,s=[],n=It(t);for(e=0;e<n.length;e++)(i=this._getItem(n[e]))&&s.push(i);return s},Mt.prototype.refreshItems=function(t){if(this._isDestroyed)return this;var i,e=this.getItems(t);for(i=0;i<e.length;i++)e[i]._refreshDimensions();return this},Mt.prototype.refreshSortData=function(t){if(this._isDestroyed)return this;var i,e=this.getItems(t);for(i=0;i<e.length;i++)e[i]._refreshSortData();return this},Mt.prototype.synchronize=function(){if(this._isDestroyed)return this;var t,i,e,s=this._element,n=this._items;if(n.length){for(e=0;e<n.length;e++)(i=n[e]._element).parentNode===s&&(t=t||document.createDocumentFragment()).appendChild(i);t&&s.appendChild(t)}return this._emit("synchronize"),this},Mt.prototype.layout=function(t,i){if(this._isDestroyed)return this;var e,n,r,o=this,h=this._element,a=this._updateLayout(),l=a.id,d=a.items.length,f=d,u="function"==typeof t?t:i,c="function"==typeof u,p=c?a.items.slice(0):null;function m(){if(!(--f>0)){var t=o._layout.id!==l;c&&u(t,p),!t&&o._hasListeners(s)&&o._emit(s,a.items.slice(0))}}if((a.setHeight&&"number"==typeof a.height||a.setWidth&&"number"==typeof a.width)&&(e="border-box"===_(h,"box-sizing")),a.setHeight&&("number"==typeof a.height?h.style.height=(e?a.height+this._borderTop+this._borderBottom:a.height)+"px":h.style.height=a.height),a.setWidth&&("number"==typeof a.width?h.style.width=(e?a.width+this._borderLeft+this._borderRight:a.width)+"px":h.style.width=a.width),this._hasListeners("layoutStart")&&this._emit("layoutStart",a.items.slice(0)),!d)return m(),this;for(r=0;r<d;r++)(n=a.items[r])&&(n._left=a.slots[2*r],n._top=a.slots[2*r+1],n.isDragging()?m():n._layout.start(!0===t,m));return this},Mt.prototype.add=function(t,i){if(this._isDestroyed||!t)return[];var e=It(t);if(!e.length)return e;var s,n,r=i||0,o=r.layout?r.layout:void 0===r.layout,h=this._items,a=!1;for(n=0;n<e.length;n++)s=new St(this,e[n],r.isActive),e[n]=s,s._isActive&&(a=!0,s._layout._skipNextAnimation=!0);return j(h,e,r.index),this._hasListeners("add")&&this._emit("add",e.slice(0)),a&&o&&this.layout("instant"===o,"function"==typeof o?o:void 0),e},Mt.prototype.remove=function(t,i){if(this._isDestroyed)return this;var e,s,n=i||0,r=n.layout?n.layout:void 0===n.layout,o=!1,h=this.getItems(),a=this.getItems(t),_=[];for(s=0;s<a.length;s++)e=a[s],_.push(h.indexOf(e)),e._isActive&&(o=!0),e._destroy(n.removeElements);return this._hasListeners("remove")&&this._emit("remove",a.slice(0),_),o&&r&&this.layout("instant"===r,"function"==typeof r?r:void 0),a},Mt.prototype.show=function(t,i){return this._isDestroyed?this:(this._setItemsVisibility(t,!0,i),this)},Mt.prototype.hide=function(t,i){return this._isDestroyed?this:(this._setItemsVisibility(t,!1,i),this)},Mt.prototype.filter=function(t,i){if(this._isDestroyed||!this._items.length)return this;var e,s,n=[],r=[],o="string"==typeof t,h="function"==typeof t,a=i||0,_=!0===a.instant,l=a.layout?a.layout:void 0===a.layout,d="function"==typeof a.onFinish?a.onFinish:null,f=-1,u=Et;if(d&&(u=function(){++f&&d(n.slice(0),r.slice(0))}),h||o)for(s=0;s<this._items.length;s++)e=this._items[s],(h?t(e):C(e._element,t))?n.push(e):r.push(e);return n.length?this.show(n,{instant:_,onFinish:u,layout:!1}):u(),r.length?this.hide(r,{instant:_,onFinish:u,layout:!1}):u(),(n.length||r.length)&&(this._hasListeners("filter")&&this._emit("filter",n.slice(0),r.slice(0)),l&&this.layout("instant"===l,"function"==typeof l?l:void 0)),this},Mt.prototype.sort=function(){var t,e,s,n;function r(t){for(var i={},e=0;e<t.length;e++)i[t[e]._id]=e;return i}function o(t,i){var s=n[t._id],r=n[i._id];return e?r-s:s-r}function h(i,h){for(var a,_,l,d,f=0,u=0;u<t.length;u++)if(a=t[u][0],_=t[u][1],l=(i._sortData?i:i._refreshSortData())._sortData[a],d=(h._sortData?h:h._refreshSortData())._sortData[a],f="desc"===_||!_&&e?d<l?-1:d>l?1:0:l<d?-1:l>d?1:0)return f;return f||(n||(n=r(s)),f=o(i,h)),f}function a(i,h){var a=t(i,h);return e&&a&&(a=-a),a||(n||(n=r(s)),o(i,h))}return function(r,o){if(this._isDestroyed||this._items.length<2)return this;var _,l=this._items,d=o||0,f=d.layout?d.layout:void 0===d.layout;if(t=r,e=!!d.descending,s=l.slice(0),n=null,"function"==typeof t)l.sort(a);else if("string"==typeof t)t=r.trim().split(" ").map(function(t){return t.split(":")}),l.sort(h);else{if(!Array.isArray(t))return this;if(t.length!==l.length)throw new Error("["+i+"] sort reference items do not match with grid items.");for(_=0;_<l.length;_++){if(t.indexOf(l[_])<0)throw new Error("["+i+"] sort reference items do not match with grid items.");l[_]=t[_]}e&&l.reverse()}return this._hasListeners("sort")&&this._emit("sort",l.slice(0),s),f&&this.layout("instant"===f,"function"==typeof f?f:void 0),this}}(),Mt.prototype.move=function(t,i,e){if(this._isDestroyed||this._items.length<2)return this;var s,n,r=this._items,o=e||0,h=o.layout?o.layout:void 0===o.layout,a="swap"===o.action,_=a?"swap":"move",l=this._getItem(t),d=this._getItem(i);return l&&d&&l!==d&&(s=r.indexOf(l),n=r.indexOf(d),a?M(r,s,n):E(r,s,n),this._hasListeners("move")&&this._emit("move",{item:l,fromIndex:s,toIndex:n,action:_}),h&&this.layout("instant"===h,"function"==typeof h?h:void 0)),this},Mt.prototype.send=function(t,i,e,s){if(this._isDestroyed||i._isDestroyed||this===i)return this;if(!(t=this._getItem(t)))return this;var n=s||0,r=n.appendTo||document.body,o=n.layoutSender?n.layoutSender:void 0===n.layoutSender,h=n.layoutReceiver?n.layoutReceiver:void 0===n.layoutReceiver;return t._migrate.start(i,e,r),t._migrate._isActive&&t._isActive&&(o&&this.layout("instant"===o,"function"==typeof o?o:void 0),h&&i.layout("instant"===h,"function"==typeof h?h:void 0)),this},Mt.prototype.destroy=function(t){if(this._isDestroyed)return this;var i,s=this._element,n=this._items.slice(0);for(this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),i=0;i<n.length;i++)n[i]._destroy(t);return K(s,this._settings.containerClass),s.style.height="",s.style.width="",this._emit("destroy"),this._emitter.destroy(),e[this._id]=void 0,this._isDestroyed=!0,this},Mt.prototype._getItem=function(t){if(this._isDestroyed||!t&&0!==t)return null;if("number"==typeof t)return this._items[t>-1?t:this._items.length+t]||null;if(t instanceof St)return t._gridId===this._id?t:null;for(var i=0;i<this._items.length;i++)if(this._items[i]._element===t)return this._items[i];return null},Mt.prototype._updateLayout=function(){var t,i,e,s,n=this._layout,r=this._settings.layout;for(++n.id,n.items.length=0,s=0;s<this._items.length;s++)this._items[s]._isActive&&n.items.push(this._items[s]);return this._refreshDimensions(),t=this._width-this._borderLeft-this._borderRight,i=this._height-this._borderTop-this._borderBottom,e="function"==typeof r?r(n.items,t,i):Lt.getLayout(n.items,t,i,n.slots,r),n.slots=e.slots,n.setWidth=Boolean(e.setWidth),n.setHeight=Boolean(e.setHeight),n.width=e.width,n.height=e.height,n},Mt.prototype._emit=function(){this._isDestroyed||this._emitter.emit.apply(this._emitter,arguments)},Mt.prototype._hasListeners=function(t){var i=this._emitter._events[t];return!(!i||!i.length)},Mt.prototype._updateBoundingRect=function(){var t=this._element.getBoundingClientRect();this._width=t.width,this._height=t.height,this._left=t.left,this._top=t.top},Mt.prototype._updateBorders=function(t,i,e,s){var n=this._element;t&&(this._borderLeft=k(n,"border-left-width")),i&&(this._borderRight=k(n,"border-right-width")),e&&(this._borderTop=k(n,"border-top-width")),s&&(this._borderBottom=k(n,"border-bottom-width"))},Mt.prototype._refreshDimensions=function(){this._updateBoundingRect(),this._updateBorders(1,1,1,1)},Mt.prototype._setItemsVisibility=function(t,i,e){var s,n,r=this,o=this.getItems(t),h=e||0,a=!0===h.instant,_=h.onFinish,l=h.layout?h.layout:void 0===h.layout,d=o.length,f=i?"showStart":"hideStart",u=i?"showEnd":"hideEnd",c=i?"show":"hide",p=!1,m=[],g=[];if(d){for(this._hasListeners(f)&&this._emit(f,o.slice(0)),n=0;n<o.length;n++)s=o[n],(i&&!s._isActive||!i&&s._isActive)&&(p=!0),i&&!s._isActive&&(s._layout._skipNextAnimation=!0),i&&s._visibility._isHidden&&g.push(s),s._visibility[c](a,function(t,i){t||m.push(i),--d<1&&("function"==typeof _&&_(m.slice(0)),r._hasListeners(u)&&r._emit(u,m.slice(0)))});g.length&&this.refreshItems(g),p&&l&&this.layout("instant"===l,"function"==typeof l?l:void 0)}else"function"==typeof _&&_(o)},Mt}); | ||
* Muuri v0.8.0 | ||
* https://github.com/haltu/muuri | ||
* Copyright (c) 2015-present, Haltu Oy | ||
* Released under the MIT license | ||
* https://github.com/haltu/muuri/blob/master/LICENSE.md | ||
* @license MIT | ||
* | ||
* Muuri Packer | ||
* Copyright (c) 2016-present, Niklas Rämö <inramo@gmail.com> | ||
* @license MIT | ||
* | ||
* Muuri Ticker / Muuri Emitter / Muuri Queue | ||
* Copyright (c) 2018-present, Niklas Rämö <inramo@gmail.com> | ||
* @license MIT | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Muuri=e()}(this,function(){"use strict";var t={},e="layoutEnd";function i(){this._events={},this._queue=[],this._counter=0,this._isDestroyed=!1}i.prototype.on=function(t,e){if(this._isDestroyed)return this;var i=this._events[t];return i||(i=this._events[t]=[]),i.push(e),this},i.prototype.off=function(t,e){if(this._isDestroyed)return this;var i=this._events[t];if(!i||!i.length)return this;if(!e)return i.length=0,this;for(var s=i.length;s--;)e===i[s]&&i.splice(s,1);return this},i.prototype.emit=function(t,e,i,s){if(this._isDestroyed)return this;var n=this._events[t];if(!n||!n.length)return this;var r,o=this._queue,h=o.length,a=arguments.length-1;for(r=0;r<n.length;r++)o.push(n[r]);for(++this._counter,r=h,h=o.length;r<h;r++)if(0===a?o[r]():1===a?o[r](e):2===a?o[r](e,i):o[r](e,i,s),this._isDestroyed)return this;return--this._counter,this._counter||(o.length=0),this},i.prototype.destroy=function(){if(this._isDestroyed)return this;var t,e=this._events;for(t in this._isDestroyed=!0,this._queue.length=this._counter=0,e)e[t]&&(e[t].length=0,e[t]=void 0);return this};var s="transform",n="transform",r=window.document.documentElement.style,o=!1;["","Webkit","Moz","O","ms"].forEach(function(t){if(!o){var e=t?t+"Transform":"transform";void 0!==r[e]&&(t=t.toLowerCase(),s=t?"-"+t+"-transform":"transform",n=e,o=!0)}});var h="function"==typeof WeakMap?new WeakMap:null;function a(t,e){var i=h&&h.get(t);return i||(i=window.getComputedStyle(t,null),h&&h.set(t,i)),i.getPropertyValue("transform"===e?s:e)}var _=/([A-Z])/g;function l(t){return t.replace(_,"-$1").toLowerCase()}var d="function";function c(t){return typeof t===d}var u="transform";function f(t,e){for(var i in e)t.style[i===u?n:i]=e[i]}function p(t){this._element=t,this._animation=null,this._callback=null,this._props=[],this._values=[],this._keyframes=[],this._options={},this._isDestroyed=!1,this._onFinish=this._onFinish.bind(this)}p.prototype.start=function(t,e,i){if(!this._isDestroyed){var s=this._animation,n=this._props,r=this._values,o=i||0,h=!1;if(s){var a,_=0;for(var l in e)if(++_,-1===(a=n.indexOf(l))||e[l]!==r[a]){h=!0;break}h||_===n.length||(h=!0)}if(h&&s.cancel(),this._callback=c(o.onFinish)?o.onFinish:null,!s||h){for(l in n.length=r.length=0,e)n.push(l),r.push(e[l]);var d=this._keyframes;d[0]=t,d[1]=e;var u=this._options;u.duration=o.duration||300,u.easing=o.easing||"ease";var p=this._element;(s=p.animate(d,u)).onfinish=this._onFinish,this._animation=s,f(p,e)}}},p.prototype.stop=function(t){if(!this._isDestroyed&&this._animation){var e,i,s,r=this._element,o=this._props,h=this._values;if(t)f(r,t);else for(s=0;s<o.length;s++)i=a(r,l(e=o[s])),r.style["transform"===e?n:e]=i;this._animation.cancel(),this._animation=this._callback=null,o.length=h.length=0}},p.prototype.isAnimating=function(){return!!this._animation},p.prototype.destroy=function(){this._isDestroyed||(this.stop(),this._element=this._options=this._keyframes=null,this._isDestroyed=!0)},p.prototype._onFinish=function(){var t=this._callback;this._animation=this._callback=null,this._props.length=this._values.length=0,t&&t()};var m=["","webkit","moz","ms","o","Webkit","Moz","MS","O"];function g(t,e){for(var i,s,n=e[0].toUpperCase()+e.slice(1),r=0;r<m.length;){if((s=(i=m[r])?i+n:e)in t)return s;++r}return null}var y=(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return this.setTimeout(function(){t(1e3/60)},1e3/60)}).bind(window),v=!1;try{var w=Object.defineProperty({},"passive",{get:function(){v=!0}});window.addEventListener("testPassive",null,w),window.removeEventListener("testPassive",null,w)}catch(t){}var S="start",D="move",b="end",A="cancel",E=!!("ontouchstart"in window||window.TouchEvent),C=!!window.PointerEvent,L=!!window.navigator.msPointerEnabled,I=/(android)/i.test(window.navigator.userAgent),R=!!v&&{passive:!0},x=g(window.document.documentElement.style,"touchAction"),P="auto";function M(t,e){this._element=t,this._emitter=new i,this._isDestroyed=!1,this._cssProps={},this._touchAction="",this._startEvent=null,this._pointerId=null,this._startTime=0,this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._preStartCheck=this._preStartCheck.bind(this),this._abortNonCancelable=this._abortNonCancelable.bind(this),this._onStart=this._onStart.bind(this),this._onMove=this._onMove.bind(this),this._onCancel=this._onCancel.bind(this),this._onEnd=this._onEnd.bind(this),this.setCssProps(e),this._touchAction||this.setTouchAction(P),t.addEventListener("dragstart",M._preventDefault,!1),t.addEventListener(M._events.start,this._preStartCheck,R),!E||C||L||t.addEventListener(M._mouseEvents.start,this._preStartCheck,R)}function T(){this._nextStep=null,this._queue=[],this._reads={},this._writes={},this._batch=[],this._batchReads={},this._batchWrites={},this._step=this._step.bind(this)}M._pointerEvents={start:"pointerdown",move:"pointermove",cancel:"pointercancel",end:"pointerup"},M._msPointerEvents={start:"MSPointerDown",move:"MSPointerMove",cancel:"MSPointerCancel",end:"MSPointerUp"},M._touchEvents={start:"touchstart",move:"touchmove",cancel:"touchcancel",end:"touchend"},M._mouseEvents={start:"mousedown",move:"mousemove",cancel:"",end:"mouseup"},M._events=C?M._pointerEvents:L?M._msPointerEvents:E?M._touchEvents:M._mouseEvents,M._emitter=new i,M._activeInstances=[],M._preventDefault=function(t){t.preventDefault&&!1!==t.cancelable&&t.preventDefault()},M._activateInstance=function(t){M._activeInstances.indexOf(t)>-1||(M._activeInstances.push(t),M._emitter.on(D,t._onMove),M._emitter.on(A,t._onCancel),M._emitter.on(b,t._onEnd),1===M._activeInstances.length&&M._bindListeners())},M._deactivateInstance=function(t){var e=M._activeInstances.indexOf(t);-1!==e&&(M._activeInstances.splice(e,1),M._emitter.off(D,t._onMove),M._emitter.off(A,t._onCancel),M._emitter.off(b,t._onEnd),M._activeInstances.length||M._unbindListeners())},M._bindListeners=function(){var t=M._events;window.addEventListener(t.move,M._onMove,R),window.addEventListener(t.end,M._onEnd,R),t.cancel&&window.addEventListener(t.cancel,M._onCancel,R)},M._unbindListeners=function(){var t=M._events;window.removeEventListener(t.move,M._onMove,R),window.removeEventListener(t.end,M._onEnd,R),t.cancel&&window.removeEventListener(t.cancel,M._onCancel,R)},M._getEventPointerId=function(t){return"number"==typeof t.pointerId?t.pointerId:t.changedTouches?t.changedTouches[0]?t.changedTouches[0].identifier:null:1},M._getTouchById=function(t,e){if("number"==typeof t.pointerId)return t.pointerId===e?t:null;if(t.changedTouches){for(var i=0;i<t.changedTouches.length;i++)if(t.changedTouches[i].identifier===e)return t.changedTouches[i];return null}return t},M._onMove=function(t){M._emitter.emit(D,t)},M._onCancel=function(t){M._emitter.emit(A,t)},M._onEnd=function(t){M._emitter.emit(b,t)},M.prototype._reset=function(){this._isDestroyed||(this._pointerId=null,this._startTime=0,this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._startEvent=null,this._element.removeEventListener(M._touchEvents.start,this._abortNonCancelable,R),M._deactivateInstance(this))},M.prototype._createEvent=function(t,e){var i=this._getTrackedTouch(e);return{type:t,srcEvent:e,distance:this.getDistance(),deltaX:this.getDeltaX(),deltaY:this.getDeltaY(),deltaTime:t===S?0:this.getDeltaTime(),isFirst:t===S,isFinal:t===b||t===A,identifier:this._pointerId,screenX:i.screenX,screenY:i.screenY,clientX:i.clientX,clientY:i.clientY,pageX:i.pageX,pageY:i.pageY,target:i.target}},M.prototype._emit=function(t,e){this._emitter.emit(t,this._createEvent(t,e))},M.prototype._getTrackedTouch=function(t){return null===this._pointerId?null:M._getTouchById(t,this._pointerId)},M.prototype._preStartCheck=function(t){this._isDestroyed||this.isDragging()||I&&!1===t.cancelable||t.button||(this._pointerId=M._getEventPointerId(t),null!==this._pointerId&&(this._startEvent=t,E&&(C||L)?(I&&this._element.addEventListener(M._touchEvents.start,this._abortNonCancelable,R),y(this._onStart)):this._onStart()))},M.prototype._abortNonCancelable=function(t){this._element.removeEventListener(M._touchEvents.start,this._abortNonCancelable,R),this._startEvent&&!1===t.cancelable&&(this._pointerId=null,this._startEvent=null)},M.prototype._onStart=function(){var t=this._startEvent;if(t){this._startEvent=null;var e=this._getTrackedTouch(t);e&&(this._startX=this._currentX=e.clientX,this._startY=this._currentY=e.clientY,this._startTime=Date.now(),this._emit(S,t),M._activateInstance(this))}},M.prototype._onMove=function(t){var e=this._getTrackedTouch(t);e&&(this._currentX=e.clientX,this._currentY=e.clientY,this._emit(D,t))},M.prototype._onCancel=function(t){this._getTrackedTouch(t)&&(this._emit(A,t),this._reset())},M.prototype._onEnd=function(t){this._getTrackedTouch(t)&&(this._emit(b,t),this._reset())},M.prototype.isDragging=function(){return null!==this._pointerId},M.prototype.setTouchAction=function(t){this._touchAction=t,x&&(this._cssProps[x]="",this._element.style[x]=t),E&&(this._element.removeEventListener(M._touchEvents.start,M._preventDefault,!1),this._element.style[x]!==t&&this._element.addEventListener(M._touchEvents.start,M._preventDefault,!1))},M.prototype.setCssProps=function(t){if(t){var e,i,s=this._cssProps,n=this._element;for(e in s)n.style[e]=s[e],delete s[e];for(e in t)t[e]&&("touchAction"!==e?(i=g(n.style,e))&&(s[i]="",n.style[i]=t[e]):this.setTouchAction(t[e]))}},M.prototype.getDeltaX=function(){return this._currentX-this._startX},M.prototype.getDeltaY=function(){return this._currentY-this._startY},M.prototype.getDistance=function(){var t=this.getDeltaX(),e=this.getDeltaY();return Math.sqrt(t*t+e*e)},M.prototype.getDeltaTime=function(){return this._startTime?Date.now()-this._startTime:0},M.prototype.on=function(t,e){this._emitter.on(t,e)},M.prototype.off=function(t,e){this._emitter.off(eventName,e)},M.prototype.destroy=function(){if(!this._isDestroyed){var t=this._element,e=M._events;for(var i in this._reset(),this._emitter.destroy(),t.removeEventListener(e.start,this._preStartCheck,R),t.removeEventListener(M._mouseEvents.start,this._preStartCheck,R),t.removeEventListener("dragstart",M._preventDefault,!1),t.removeEventListener(M._touchEvents.start,M._preventDefault,!1),this._cssProps)t.style[i]=this._cssProps[i],delete this._cssProps[i];this._element=null,this._isDestroyed=!0}},T.prototype.add=function(t,e,i,s){var n=this._queue.indexOf(t);n>-1&&(this._queue[n]=void 0),s?this._queue.unshift(t):this._queue.push(t),this._reads[t]=e,this._writes[t]=i,this._nextStep||(this._nextStep=y(this._step))},T.prototype.cancel=function(t){var e=this._queue.indexOf(t);e>-1&&(this._queue[e]=void 0,delete this._reads[t],delete this._writes[t])},T.prototype._step=function(){var t,e,i=this._queue,s=this._reads,n=this._writes,r=this._batch,o=this._batchReads,h=this._batchWrites,a=i.length;for(this._nextStep=null,e=0;e<a;e++)(t=i[e])&&(r.push(t),o[t]=s[t],delete s[t],h[t]=n[t],delete n[t]);for(i.length=0,e=0;e<a;e++)o[t=r[e]]&&(o[t](),delete o[t]);for(e=0;e<a;e++)h[t=r[e]]&&(h[t](),delete h[t]);r.length=0,!this._nextStep&&i.length&&(this._nextStep=y(this._step))};var k=new T,X="layout",Y="visibility",G="move",H="scroll",O="placeholder";function B(t){return k.cancel(t+Y)}function N(t){return k.cancel(t+G)}function q(t){return k.cancel(t+H)}function F(t){return k.cancel(t+O)}var z=window.Element.prototype,V=z.matches||z.matchesSelector||z.webkitMatchesSelector||z.mozMatchesSelector||z.msMatchesSelector||z.oMatchesSelector||function(){return!1};function W(t,e){return V.call(t,e)}function j(t,e){t.classList?t.classList.add(e):W(t,"."+e)||(t.className+=" "+e)}var U=[],Z="number";function $(t,e,i){var s=typeof i===Z?i:-1;s<0&&(s=t.length-s+1),t.splice.apply(t,U.concat(s,0,e)),U.length=0}function J(t,e,i){var s=t.length,n=Math.max(0,i?s:s-1);return e>n?n:e<0?Math.max(n+e+1,0):e}function K(t,e,i){if(!(t.length<2)){var s=J(t,e),n=J(t,i);s!==n&&t.splice(n,0,t.splice(s,1)[0])}}function Q(t,e,i){if(!(t.length<2)){var s,n=J(t,e),r=J(t,i);n!==r&&(s=t[n],t[n]=t[r],t[r]=s)}}var tt="cancel",et="finish",it="debounce",st=0;function nt(t,e){var i,s=++st+it;return e>0?function(n){void 0!==i&&(i=window.clearTimeout(i),k.cancel(s),n===et&&t()),n!==tt&&n!==et&&(i=window.setTimeout(function(){i=void 0,k.add(s,t,null,!0)},e))}:function(e){e!==tt&&t()}}function rt(t){var e=a(t,"transform");if(!e||"none"===e)return!1;var i=a(t,"display");return"inline"!==i&&"none"!==i}function ot(t,e){for(var i=window.document,s=(e?t:t.parentElement)||i;s&&s!==i&&"static"===a(s,"position")&&!rt(s);)s=s.parentElement||i;return s}function ht(t,e){return parseFloat(a(t,e))||0}var at={},_t={},lt={};function dt(t,e){var i,s=e||{};return s.left=0,s.top=0,t===document?s:(s.left=window.pageXOffset||0,s.top=window.pageYOffset||0,t.self===window.self?s:(i=t.getBoundingClientRect(),s.left+=i.left,s.top+=i.top,s.left+=ht(t,"border-left-width"),s.top+=ht(t,"border-top-width"),s))}function ct(t,e,i){return lt.left=0,lt.top=0,t===e?lt:i&&(t=ot(t,!0))===(e=ot(e,!0))?lt:(dt(t,at),dt(e,_t),lt.left=_t.left-at.left,lt.top=_t.top-at.top,lt)}var ut="overflow",ft="overflow-x",pt="overflow-y",mt="auto",gt="scroll";function yt(t){var e=a(t,ut);return e===mt||e===gt||((e=a(t,ft))===mt||e===gt||((e=a(t,pt))===mt||e===gt))}function vt(t,e,i){for(var s=i||[],n=e?t:t.parentNode;n&&n!==document;)n.getRootNode&&n instanceof DocumentFragment?n=n.getRootNode().host:(yt(n)&&s.push(n),n=n.parentNode);return s.push(window),s}var wt={},St="transform",Dt="none",bt=/^matrix3d/,At=/([^,]*,){4}/,Et=/([^,]*,){12}/,Ct=/[^,]*,/;function Lt(t){wt.x=0,wt.y=0;var e=a(t,St);if(!e||e===Dt)return wt;var i=bt.test(e),s=e.replace(i?Et:At,""),n=s.replace(Ct,"");return wt.x=parseFloat(s)||0,wt.y=parseFloat(n)||0,wt}function It(t,e){return"translateX("+t+"px) translateY("+e+"px)"}function Rt(t,e){t.classList?t.classList.remove(e):W(t,"."+e)&&(t.className=(" "+t.className+" ").replace(" "+e+" "," ").trim())}var xt,Pt,Mt,Tt,kt=0;function Xt(t){var e=t._element,i=t.getGrid(),s=i._settings;this._item=t,this._gridId=i._id,this._isDestroyed=!1,this._isMigrating=!1,this._startPredicate=c(s.dragStartPredicate)?s.dragStartPredicate:Xt.defaultStartPredicate,this._startPredicateState=kt,this._startPredicateResult=void 0,this._hBlockedIndex=null,this._hX1=0,this._hX2=0,this._hY1=0,this._hY2=0,this._reset(),this._preStartCheck=this._preStartCheck.bind(this),this._preEndCheck=this._preEndCheck.bind(this),this._onScroll=this._onScroll.bind(this),this._prepareMove=this._prepareMove.bind(this),this._applyMove=this._applyMove.bind(this),this._prepareScroll=this._prepareScroll.bind(this),this._applyScroll=this._applyScroll.bind(this),this._checkOverlap=this._checkOverlap.bind(this);var n=s.dragSortHeuristics.sortInterval;this._checkOverlapDebounce=nt(this._checkOverlap,n),this._dragger=new M(e,s.dragCssProps),this._dragger.on("start",this._preStartCheck),this._dragger.on("move",this._preStartCheck),this._dragger.on("cancel",this._preEndCheck),this._dragger.on("end",this._preEndCheck)}function Yt(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?0:(Math.min(t.left+t.width,e.left+e.width)-Math.max(t.left,e.left))*(Math.min(t.top+t.height,e.top+e.height)-Math.max(t.top,e.top))/(Math.min(t.width,e.width)*Math.min(t.height,e.height))*100}function Gt(t){this._item=t,this._animate=new p,this._element=null,this._className="",this._didMigrate=!1,this._resetAfterLayout=!1,this._currentLeft=0,this._currentTop=0,this._nextLeft=0,this._nextTop=0,this._setupAnimation=this._setupAnimation.bind(this),this._startAnimation=this._startAnimation.bind(this),this._onLayoutStart=this._onLayoutStart.bind(this),this._onLayoutEnd=this._onLayoutEnd.bind(this),this._onReleaseEnd=this._onReleaseEnd.bind(this),this._onMigrate=this._onMigrate.bind(this)}function Ht(){this._queue=[],this._isDestroyed=!1}function Ot(t){this._item=t,this._isActive=!1,this._isDestroyed=!1,this._isInterrupted=!1,this._currentStyles={},this._targetStyles={},this._currentLeft=0,this._currentTop=0,this._offsetLeft=0,this._offsetTop=0,this._skipNextAnimation=!1,this._animateOptions={onFinish:this._finish.bind(this)},this._queue=new Ht,this._setupAnimation=this._setupAnimation.bind(this),this._startAnimation=this._startAnimation.bind(this)}Xt.defaultStartPredicate=function(t,e,i){var s=t._drag,n=s._startPredicateData||s._setupStartPredicate(i);if(!e.isFinal)return!(!n.handleElement&&(n.handleElement=s._getStartPredicateHandle(e),!n.handleElement))&&(n.delay&&(n.event=e,n.delayTimer||(n.delayTimer=window.setTimeout(function(){n.delay=0,s._resolveStartPredicate(n.event)&&(s._forceResolveStartPredicate(n.event),s._resetStartPredicate())},n.delay))),s._resolveStartPredicate(e));s._finishStartPredicate(e)},Xt.defaultSortPredicate=(xt={},Pt={},Mt={},Tt=[],function(t,e){var i=t._drag,s=i._getGrid(),n=e&&"number"==typeof e.threshold?e.threshold:50,r=e&&"swap"===e.action?"swap":"move";xt.width=t._width,xt.height=t._height,xt.left=i._elementClientX,xt.top=i._elementClientY;var o=function(t,e,i){var s,n,r,o,h=null,a=e._settings.dragSort,_=-1;if(!0===a?(Tt[0]=e,n=Tt):n=a.call(e,t),!Array.isArray(n))return h;for(o=0;o<n.length;o++)(r=n[o])._isDestroyed||(r._updateBoundingRect(),Pt.width=r._width,Pt.height=r._height,Pt.left=r._left,Pt.top=r._top,(s=Yt(xt,Pt))>i&&s>_&&(_=s,h=r));return Tt.length=0,h}(t,s,n);if(!o)return!1;var h,a,_,l,d,c=0,u=0,f=-1;for(o===s?(xt.left=i._gridX+t._marginLeft,xt.top=i._gridY+t._marginTop):(o._updateBorders(1,0,1,0),c=o._left+o._borderLeft,u=o._top+o._borderTop),d=0;d<o._items.length;d++)(_=o._items[d])._isActive&&_!==t&&(a=!0,Pt.width=_._width,Pt.height=_._height,Pt.left=_._left+_._marginLeft+c,Pt.top=_._top+_._marginTop+u,(l=Yt(xt,Pt))>f&&(h=d,f=l));return f<n&&t.getGrid()!==o&&(h=a?-1:0,f=1/0),f>=n&&(Mt.grid=o,Mt.index=h,Mt.action=r,Mt)}),Xt.prototype.stop=function(){var t=this._item,e=t._element,i=this._getGrid();return this._isActive?this._isMigrating?(this._finishMigration(),this):(N(t._id),q(t._id),this._unbindScrollListeners(),this._checkOverlapDebounce("cancel"),e.parentNode!==i._element&&(i._element.appendChild(e),e.style[n]=It(this._gridX,this._gridY)),Rt(e,i._settings.itemDraggingClass),this._reset(),this):this},Xt.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(),this._dragger.destroy(),this._isDestroyed=!0,this)},Xt.prototype._getGrid=function(){return t[this._gridId]||null},Xt.prototype._reset=function(){this._isActive=!1,this._container=null,this._containingBlock=null,this._dragEvent=null,this._scrollEvent=null,this._scrollers=[],this._left=0,this._top=0,this._gridX=0,this._gridY=0,this._elementClientX=0,this._elementClientY=0,this._containerDiffX=0,this._containerDiffY=0},Xt.prototype._bindScrollListeners=function(){var t,e,i=this._getGrid()._element,s=this._container,n=this._scrollers;if(n.length=0,vt(this._item._element,!1,n),s!==i)for(vt(i,!0,t=[]),e=0;e<t.length;e++)n.indexOf(t[e])<0&&n.push(t[e]);for(e=0;e<n.length;e++)n[e].addEventListener("scroll",this._onScroll)},Xt.prototype._unbindScrollListeners=function(){var t,e=this._scrollers;for(t=0;t<e.length;t++)e[t].removeEventListener("scroll",this._onScroll);e.length=0},Xt.prototype._setupStartPredicate=function(t){var e=t||this._getGrid()._settings.dragStartPredicate||0;return this._startPredicateData={distance:Math.abs(e.distance)||0,delay:Math.max(e.delay,0)||0,handle:"string"==typeof e.handle&&e.handle}},Xt.prototype._getStartPredicateHandle=function(t){var e=this._startPredicateData,i=this._item._element,s=i;if(!e.handle)return s;for(s=t.target;s&&!W(s,e.handle);)s=s!==i?s.parentElement:null;return s||null},Xt.prototype._resolveStartPredicate=function(t){var e=this._startPredicateData;if(!(t.distance<e.distance||e.delay)){var i=e.handleElement.getBoundingClientRect(),s=i.left+(window.pageXOffset||0),n=i.top+(window.pageYOffset||0),r=i.width,o=i.height;return this._resetStartPredicate(),r&&o&&t.pageX>=s&&t.pageX<s+r&&t.pageY>=n&&t.pageY<n+o}},Xt.prototype._forceResolveStartPredicate=function(t){this._isDestroyed||1!==this._startPredicateState||(this._startPredicateState=2,this._onStart(t))},Xt.prototype._finishStartPredicate=function(t){var e=this._item._element,i=Math.abs(t.deltaX)<2&&Math.abs(t.deltaY)<2&&t.deltaTime<200;this._resetStartPredicate(),i&&function(t){if("a"!==t.tagName.toLowerCase())return;var e=t.getAttribute("href");if(!e)return;var i=t.getAttribute("target");i&&"_self"!==i?window.open(e,i):window.location.href=e}(e)},Xt.prototype._resetHeuristics=function(t){this._hBlockedIndex=null,this._hX1=this._hX2=t.clientX,this._hY1=this._hY2=t.clientY},Xt.prototype._checkHeuristics=function(t){var e=this._getGrid()._settings.dragSortHeuristics,i=e.minDragDistance;if(i<=0)return this._hBlockedIndex=null,!0;var s=t.clientX,n=t.clientY,r=s-this._hX2,o=n-this._hY2,h=i>3&&e.minBounceBackAngle>0;if(h||(this._hBlockedIndex=null),Math.abs(r)>i||Math.abs(o)>i){if(h){var a=Math.atan2(r,o),_=Math.atan2(this._hX2-this._hX1,this._hY2-this._hY1),l=Math.atan2(Math.sin(a-_),Math.cos(a-_));Math.abs(l)>e.minBounceBackAngle&&(this._hBlockedIndex=null)}return this._hX1=this._hX2,this._hY1=this._hY2,this._hX2=s,this._hY2=n,!0}return!1},Xt.prototype._resetStartPredicate=function(){var t=this._startPredicateData;t&&(t.delayTimer&&(t.delayTimer=window.clearTimeout(t.delayTimer)),this._startPredicateData=null)},Xt.prototype._checkOverlap=function(){if(this._isActive){var t,e,i,s,n,r,o,h=this._item,a=this._getGrid()._settings;(t=c(a.dragSortPredicate)?a.dragSortPredicate(h,this._dragEvent):Xt.defaultSortPredicate(h,a.dragSortPredicate))&&"number"==typeof t.index&&(o=(e=h.getGrid())!==(s=t.grid||e),i=e._items.indexOf(h),n=J(s._items,t.index,o),r="swap"===t.action?"swap":"move",(o||n!==this._hBlockedIndex)&&(o?(this._hBlockedIndex=null,e._hasListeners("beforeSend")&&e._emit("beforeSend",{item:h,fromGrid:e,fromIndex:i,toGrid:s,toIndex:n}),s._hasListeners("beforeReceive")&&s._emit("beforeReceive",{item:h,fromGrid:e,fromIndex:i,toGrid:s,toIndex:n}),h._gridId=s._id,this._isMigrating=h._gridId!==this._gridId,e._items.splice(i,1),$(s._items,h,n),h._sortData=null,e._hasListeners("send")&&e._emit("send",{item:h,fromGrid:e,fromIndex:i,toGrid:s,toIndex:n}),s._hasListeners("receive")&&s._emit("receive",{item:h,fromGrid:e,fromIndex:i,toGrid:s,toIndex:n}),e.layout(),s.layout()):i!==n&&(this._hBlockedIndex=i,("swap"===r?Q:K)(e._items,i,n),e._hasListeners("move")&&e._emit("move",{item:h,fromIndex:i,toIndex:n,action:r}),e.layout())))}},Xt.prototype._finishMigration=function(){var t,e,i=this._item,s=i._release,r=i._element,o=i._isActive,h=i.getGrid(),a=h._element,_=h._settings,l=_.dragContainer||a,d=this._getGrid()._settings,c=r.parentNode;this._isMigrating=!1,this.destroy(),Rt(r,d.itemClass),Rt(r,d.itemVisibleClass),Rt(r,d.itemHiddenClass),j(r,_.itemClass),j(r,o?_.itemVisibleClass:_.itemHiddenClass),l!==c&&(l.appendChild(r),e=ct(c,l,!0),(t=Lt(r)).x-=e.left,t.y-=e.top),i._refreshDimensions(),i._refreshSortData(),e=ct(l,a,!0),s._containerDiffX=e.left,s._containerDiffY=e.top,i._drag=_.dragEnabled?new Xt(i):null,l!==c&&(r.style[n]=It(t.x,t.y)),i._child.removeAttribute("style"),f(i._child,o?_.visibleStyles:_.hiddenStyles),s.start()},Xt.prototype._preStartCheck=function(t){this._startPredicateState===kt&&(this._startPredicateState=1),1===this._startPredicateState?(this._startPredicateResult=this._startPredicate(this._item,t),!0===this._startPredicateResult?(this._startPredicateState=2,this._onStart(t)):!1===this._startPredicateResult&&(this._startPredicateState=3)):2===this._startPredicateState&&this._isActive&&this._onMove(t)},Xt.prototype._preEndCheck=function(t){var e=2===this._startPredicateState;this._startPredicate(this._item,t),this._startPredicateState=kt,e&&this._isActive&&this._onEnd(t)},Xt.prototype._onStart=function(t){var e=this._item;if(e._isActive){var i,s=e._element,r=this._getGrid(),o=r._settings,h=e._release,a=e._migrate,_=r._element,l=o.dragContainer||_,d=ot(l,!0),c=Lt(s),u=c.x,f=c.y,p=s.getBoundingClientRect(),m=l!==_;this._resetHeuristics(t),m&&(i=ct(d,_)),e.isPositioning()&&e._layout.stop(!0,{transform:It(u,f)}),a._isActive&&(u-=a._containerDiffX,f-=a._containerDiffY,a.stop(!0,{transform:It(u,f)})),e.isReleasing()&&h._reset(),this._isActive=!0,this._dragEvent=t,this._container=l,this._containingBlock=d,this._elementClientX=p.left,this._elementClientY=p.top,this._left=this._gridX=u,this._top=this._gridY=f,o.dragPlaceholder.enabled&&e._dragPlaceholder.create(),r._emit("dragInit",e,t),m&&(this._containerDiffX=i.left,this._containerDiffY=i.top,s.parentNode===l?(this._gridX=u-this._containerDiffX,this._gridY=f-this._containerDiffY):(this._left=u+this._containerDiffX,this._top=f+this._containerDiffY,l.appendChild(s),s.style[n]=It(this._left,this._top))),j(s,o.itemDraggingClass),this._bindScrollListeners(),r._emit("dragStart",e,t)}},Xt.prototype._onMove=function(t){var e=this._item;if(e._isActive){var i,s,n,r=this._getGrid()._settings.dragAxis;if("y"!==r){var o=t.clientX-this._dragEvent.clientX;this._left+=o,this._gridX+=o,this._elementClientX+=o}if("x"!==r){var h=t.clientY-this._dragEvent.clientY;this._top+=h,this._gridY+=h,this._elementClientY+=h}this._dragEvent=t,i=e._id,s=this._prepareMove,n=this._applyMove,k.add(i+G,s,n,!0)}else this.stop()},Xt.prototype._prepareMove=function(){this._item._isActive&&this._getGrid()._settings.dragSort&&this._checkHeuristics(this._dragEvent)&&this._checkOverlapDebounce()},Xt.prototype._applyMove=function(){var t=this._item;t._isActive&&(t._element.style[n]=It(this._left,this._top),this._getGrid()._emit("dragMove",t,this._dragEvent))},Xt.prototype._onScroll=function(t){var e,i,s,n=this._item;n._isActive?(this._scrollEvent=t,e=n._id,i=this._prepareScroll,s=this._applyScroll,k.add(e+H,i,s,!0)):this.stop()},Xt.prototype._prepareScroll=function(){var t=this._item;if(t._isActive){var e,i=t._element,s=this._getGrid(),n=s._settings,r=n.dragAxis,o=s._element,h=i.getBoundingClientRect(),a=this._elementClientX-h.left,_=this._elementClientY-h.top;this._container!==o&&(e=ct(this._containingBlock,o),this._containerDiffX=e.left,this._containerDiffY=e.top),"y"!==r&&(this._left+=a,this._gridX=this._left-this._containerDiffX),"x"!==r&&(this._top+=_,this._gridY=this._top-this._containerDiffY),n.dragSort&&this._checkOverlapDebounce()}},Xt.prototype._applyScroll=function(){var t=this._item;t._isActive&&(t._element.style[n]=It(this._left,this._top),this._getGrid()._emit("dragScroll",t,this._scrollEvent))},Xt.prototype._onEnd=function(t){var e=this._item,i=e._element,s=this._getGrid(),n=s._settings,r=e._release;e._isActive?(N(e._id),q(e._id),n.dragSort&&this._checkOverlapDebounce("finish"),this._unbindScrollListeners(),r._containerDiffX=this._containerDiffX,r._containerDiffY=this._containerDiffY,this._reset(),Rt(i,n.itemDraggingClass),s._emit("dragEnd",e,t),this._isMigrating?this._finishMigration():r.start()):this.stop()},Gt.prototype._onLayoutStart=function(){var t=this._item,e=t.getGrid(),i=e._items.indexOf(t),s=e._layout.slots[2*i],n=e._layout.slots[2*i+1];if(this._didMigrate||t._left!==s||t._top!==n){var r,o,h;if(s+=t._marginLeft,n+=t._marginTop,!(e._settings.dragPlaceholder.duration>0)||this._didMigrate){F(t._id);var a={transform:It(s,n)};return this._animate.isAnimating()?this._animate.stop(a):f(this._element,a),void(this._didMigrate&&(e.getElement().appendChild(this._element),this._didMigrate=!1))}this._nextLeft=s,this._nextTop=n,r=t._id,o=this._setupAnimation,h=this._startAnimation,k.add(r+O,o,h)}},Gt.prototype._setupAnimation=function(){if(this.isActive()){var t=Lt(this._element);this._currentLeft=t.x,this._currentTop=t.y}},Gt.prototype._startAnimation=function(){if(this.isActive()){var t=this._animate,e=this._currentLeft,i=this._currentTop,s=this._nextLeft,n=this._nextTop,r={transform:It(s,n)};if(e!==s||i!==n){var o=this._item.getGrid()._settings.dragPlaceholder,h={transform:It(e,i)};t.start(h,r,{duration:o.duration,easing:o.easing,onFinish:this._onLayoutEnd})}else t.isAnimating()&&t.stop(r)}},Gt.prototype._onLayoutEnd=function(){this._resetAfterLayout&&this.reset()},Gt.prototype._onReleaseEnd=function(t){if(t._id===this._item._id){if(!this._animate.isAnimating())return void this.reset();this._resetAfterLayout=!0}},Gt.prototype._onMigrate=function(t){if(t.item===this._item){var e=this._item.getGrid(),i=t.toGrid;e.off("dragReleaseEnd",this._onReleaseEnd),e.off("layoutStart",this._onLayoutStart),e.off("beforeSend",this._onMigrate),i.on("dragReleaseEnd",this._onReleaseEnd),i.on("layoutStart",this._onLayoutStart),i.on("beforeSend",this._onMigrate),this._didMigrate=!0}},Gt.prototype.create=function(){if(this.isActive())this._resetAfterLayout=!1;else{var t,e=this._item,i=e.getGrid(),s=i._settings,n=this._animate;t=c(s.dragPlaceholder.createElement)?s.dragPlaceholder.createElement(e):window.document.createElement("div"),this._element=t,n._element=t,this._className=s.itemPlaceholderClass||"",this._className&&j(t,this._className);var r=e._left+e._marginLeft,o=e._top+e._marginTop;f(t,{display:"block",position:"absolute",left:"0",top:"0",width:e._width+"px",height:e._height+"px",transform:It(r,o)}),i.on("layoutStart",this._onLayoutStart),i.on("dragReleaseEnd",this._onReleaseEnd),i.on("beforeSend",this._onMigrate),c(s.dragPlaceholder.onCreate)&&s.dragPlaceholder.onCreate(e,t),i.getElement().appendChild(t)}},Gt.prototype.reset=function(){if(this.isActive()){var t=this._element,e=this._item,i=e.getGrid(),s=i._settings,n=this._animate;this._resetAfterLayout=!1,F(e._id),n.stop(),n._element=null,i.off("dragReleaseEnd",this._onReleaseEnd),i.off("layoutStart",this._onLayoutStart),i.off("beforeSend",this._onMigrate),this._className&&(Rt(t,this._className),this._className=""),t.parentNode.removeChild(t),this._element=null,c(s.dragPlaceholder.onRemove)&&s.dragPlaceholder.onRemove(e,t)}},Gt.prototype.updateDimensions=function(t,e){this.isActive()&&f(this._element,{width:t+"px",height:e+"px"})},Gt.prototype.isActive=function(){return!!this._element},Gt.prototype.destroy=function(){this.reset(),this._animate.destroy(),this._item=this._animate=null},Ht.prototype.add=function(t){return this._isDestroyed?this:(this._queue.push(t),this)},Ht.prototype.flush=function(t,e){if(this._isDestroyed)return this;var i,s=this._queue,n=s.length;if(!n)return this;var r=1===n,o=r?s[0]:s.slice(0);if(s.length=0,r)return o(t,e),this;for(i=0;i<n&&(o[i](t,e),!this._isDestroyed);i++);return this},Ht.prototype.destroy=function(){return this._isDestroyed?this:(this._isDestroyed=!0,this._queue.length=0,this)},Ot.prototype.start=function(t,e){if(!this._isDestroyed){var i,s,n,r,o=this._item,h=o._element,a=o._release,_=o.getGrid()._settings,l=this._isActive,d=a._isActive&&!1===a._isPositioningStarted,u=d?_.dragReleaseDuration:_.layoutDuration,p=d?_.dragReleaseEasing:_.layoutEasing,m=!t&&!this._skipNextAnimation&&u>0;return l&&this._queue.flush(!0,o),d&&(a._isPositioningStarted=!0),c(e)&&this._queue.add(e),m?(this._isActive=!0,this._animateOptions.easing=p,this._animateOptions.duration=u,this._isInterrupted=l,s=o._id,n=this._setupAnimation,r=this._startAnimation,k.add(s+X,n,r),this):(this._updateOffsets(),this._updateTargetStyles(),i=o._animate.isAnimating(),this.stop(!1,this._targetStyles),!i&&f(h,this._targetStyles),this._skipNextAnimation=!1,this._finish())}},Ot.prototype.stop=function(t,e){if(this._isDestroyed||!this._isActive)return this;var i,s=this._item;return i=s._id,k.cancel(i+X),s._animate.stop(e),Rt(s._element,s.getGrid()._settings.itemPositioningClass),this._isActive=!1,t&&this._queue.flush(!0,s),this},Ot.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(!0,{}),this._queue.destroy(),this._item=this._currentStyles=this._targetStyles=this._animateOptions=null,this._isDestroyed=!0,this)},Ot.prototype._updateOffsets=function(){if(!this._isDestroyed){var t=this._item,e=t._migrate,i=t._release;this._offsetLeft=i._isActive?i._containerDiffX:e._isActive?e._containerDiffX:0,this._offsetTop=i._isActive?i._containerDiffY:e._isActive?e._containerDiffY:0}},Ot.prototype._updateTargetStyles=function(){this._isDestroyed||(this._targetStyles.transform=It(this._item._left+this._offsetLeft,this._item._top+this._offsetTop))},Ot.prototype._finish=function(){if(!this._isDestroyed){var t=this._item,e=t._migrate,i=t._release;this._isActive&&(this._isActive=!1,Rt(t._element,t.getGrid()._settings.itemPositioningClass)),i._isActive&&i.stop(),e._isActive&&e.stop(),this._queue.flush(!1,t)}},Ot.prototype._setupAnimation=function(){var t=Lt(this._item._element);this._currentLeft=t.x,this._currentTop=t.y},Ot.prototype._startAnimation=function(){var t=this._item,e=t.getGrid()._settings;if(this._updateOffsets(),this._updateTargetStyles(),t._left===this._currentLeft-this._offsetLeft&&t._top===this._currentTop-this._offsetTop)return this._isInterrupted&&this.stop(!1,this._targetStyles),this._isActive=!1,void this._finish();this._isInterrupted||j(t._element,e.itemPositioningClass),this._currentStyles.transform=It(this._currentLeft,this._currentTop),t._animate.start(this._currentStyles,this._targetStyles,this._animateOptions)};var Bt={};function Nt(t){this._item=t,this._isActive=!1,this._isDestroyed=!1,this._container=!1,this._containerDiffX=0,this._containerDiffY=0}Nt.prototype.start=function(t,e,i){if(this._isDestroyed)return this;var s,r,o,h,a,_,l,d,c=this._item,u=c._element,p=c.isVisible(),m=c.getGrid(),g=m._settings,y=t._settings,v=t._element,w=t._items,S=m._items.indexOf(c),D=i||window.document.body;if("number"==typeof e)s=J(w,e,!0);else{if(!(r=t._getItem(e)))return this;s=w.indexOf(r)}return(c.isPositioning()||this._isActive||c.isReleasing())&&(l=(_=Lt(u)).x,d=_.y),c.isPositioning()&&c._layout.stop(!0,{transform:It(l,d)}),this._isActive&&(l-=this._containerDiffX,d-=this._containerDiffY,this.stop(!0,{transform:It(l,d)})),c.isReleasing()&&(l-=c._release._containerDiffX,d-=c._release._containerDiffY,c._release.stop(!0,{transform:It(l,d)})),c._visibility._stopAnimation(),c._drag&&c._drag.destroy(),c._visibility._queue.flush(!0,c),m._hasListeners("beforeSend")&&m._emit("beforeSend",{item:c,fromGrid:m,fromIndex:S,toGrid:t,toIndex:s}),t._hasListeners("beforeReceive")&&t._emit("beforeReceive",{item:c,fromGrid:m,fromIndex:S,toGrid:t,toIndex:s}),Rt(u,g.itemClass),Rt(u,g.itemVisibleClass),Rt(u,g.itemHiddenClass),j(u,y.itemClass),j(u,p?y.itemVisibleClass:y.itemHiddenClass),m._items.splice(S,1),$(w,c,s),c._gridId=t._id,D!==(o=u.parentNode)&&(D.appendChild(u),h=ct(D,o,!0),_||(l=(_=Lt(u)).x,d=_.y),u.style[n]=It(l+h.left,d+h.top)),c._child.removeAttribute("style"),f(c._child,p?y.visibleStyles:y.hiddenStyles),u.style.display=p?"block":"hidden",a=ct(D,v,!0),c._refreshDimensions(),c._refreshSortData(),c._drag=y.dragEnabled?new Xt(c):null,this._isActive=!0,this._container=D,this._containerDiffX=a.left,this._containerDiffY=a.top,m._hasListeners("send")&&m._emit("send",{item:c,fromGrid:m,fromIndex:S,toGrid:t,toIndex:s}),t._hasListeners("receive")&&t._emit("receive",{item:c,fromGrid:m,fromIndex:S,toGrid:t,toIndex:s}),this},Nt.prototype.stop=function(t,e){if(this._isDestroyed||!this._isActive)return this;var i,s=this._item,n=s._element,r=s.getGrid()._element;return this._container!==r&&(e||(t?(i=Lt(n),Bt.transform=It(i.x-this._containerDiffX,i.y-this._containerDiffY)):Bt.transform=It(s._left,s._top),e=Bt),r.appendChild(n),f(n,e)),this._isActive=!1,this._container=null,this._containerDiffX=0,this._containerDiffY=0,this},Nt.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(!0),this._item=null,this._isDestroyed=!0,this)};var qt={};function Ft(t){this._item=t,this._isActive=!1,this._isDestroyed=!1,this._isPositioningStarted=!1,this._containerDiffX=0,this._containerDiffY=0}function zt(t){var e=t._isActive,i=t._element,s=t.getGrid()._settings;this._item=t,this._isDestroyed=!1,this._isHidden=!e,this._isHiding=!1,this._isShowing=!1,this._queue=new Ht,this._finishShow=this._finishShow.bind(this),this._finishHide=this._finishHide.bind(this),i.style.display=e?"block":"none",j(i,e?s.itemVisibleClass:s.itemHiddenClass),f(t._child,e?s.visibleStyles:s.hiddenStyles)}Ft.prototype.start=function(){if(this._isDestroyed||this._isActive)return this;var t=this._item,e=t.getGrid();return this._isActive=!0,j(t._element,e._settings.itemReleasingClass),e._emit("dragReleaseStart",t),t._layout.start(!1),this},Ft.prototype.stop=function(t,e){if(this._isDestroyed||!this._isActive)return this;var i,s=this._item,n=s._element,r=s.getGrid(),o=r._element;return this._reset(),n.parentNode!==o&&(e||(t?(i=Lt(n),qt.transform=It(i.x-this._containerDiffX,i.y-this._containerDiffY)):qt.transform=It(s._left,s._top),e=qt),o.appendChild(n),f(n,e)),t||r._emit("dragReleaseEnd",s),this},Ft.prototype.destroy=function(){return this._isDestroyed?this:(this.stop(!0),this._item=null,this._isDestroyed=!0,this)},Ft.prototype._reset=function(){if(!this._isDestroyed){var t=this._item;this._isActive=!1,this._isPositioningStarted=!1,this._containerDiffX=0,this._containerDiffY=0,Rt(t._element,t.getGrid()._settings.itemReleasingClass)}},zt.prototype.show=function(t,e){if(this._isDestroyed)return this;var i=this._item,s=i._element,n=this._queue,r=c(e)?e:null,o=i.getGrid()._settings;return this._isShowing||this._isHidden?this._isShowing&&!t?(r&&n.add(r),this):(this._isShowing||(n.flush(!0,i),Rt(s,o.itemHiddenClass),j(s,o.itemVisibleClass),this._isHiding||(s.style.display="block")),r&&n.add(r),i._isActive=this._isShowing=!0,this._isHiding=this._isHidden=!1,this._startAnimation(!0,t,this._finishShow),this):(r&&r(!1,i),this)},zt.prototype.hide=function(t,e){if(this._isDestroyed)return this;var i=this._item,s=i._element,n=this._queue,r=c(e)?e:null,o=i.getGrid()._settings;return!this._isHiding&&this._isHidden?(r&&r(!1,i),this):this._isHiding&&!t?(r&&n.add(r),this):(this._isHiding||(n.flush(!0,i),j(s,o.itemHiddenClass),Rt(s,o.itemVisibleClass)),r&&n.add(r),this._isHidden=this._isHiding=!0,i._isActive=this._isShowing=!1,this._startAnimation(!1,t,this._finishHide),this)},zt.prototype.destroy=function(){if(this._isDestroyed)return this;var t=this._item,e=t._element,i=t.getGrid(),s=this._queue,n=i._settings;return this._stopAnimation({}),s.flush(!0,t).destroy(),Rt(e,n.itemVisibleClass),Rt(e,n.itemHiddenClass),this._item=null,this._isHiding=this._isShowing=!1,this._isDestroyed=this._isHidden=!0,this},zt.prototype._startAnimation=function(t,e,i){if(!this._isDestroyed){var s,n=this._item,r=n.getGrid()._settings,o=t?r.visibleStyles:r.hiddenStyles,h=parseInt(t?r.showDuration:r.hideDuration)||0,_=(t?r.showEasing:r.hideEasing)||"ease",d=e||h<=0;if(o){if(B(n._id),d)return n._animateChild.isAnimating()?n._animateChild.stop(o):f(n._child,o),void(i&&i());var c,u,p;c=n._id,u=function(){s=function(t,e){var i={};for(var s in e)i[s]=a(t,l(s));return i}(n._child,o)},p=function(){n._animateChild.start(s,o,{duration:h,easing:_,onFinish:i})},k.add(c+Y,u,p)}else i&&i()}},zt.prototype._stopAnimation=function(t){if(!this._isDestroyed){var e=this._item;B(e._id),e._animateChild.stop(t)}},zt.prototype._finishShow=function(){this._isHidden||(this._isShowing=!1,this._queue.flush(!1,this._item))};var Vt={};zt.prototype._finishHide=function(){if(this._isHidden){var t=this._item;this._isHiding=!1,Vt.transform=It(0,0),t._layout.stop(!0,Vt),t._element.style.display="none",this._queue.flush(!1,t)}};var Wt,jt,Ut,Zt,$t=0;function Jt(){return++$t}function Kt(t,e,i){var s=t._settings;this._id=Jt(),this._gridId=t._id,this._isDestroyed=!1,this._left=0,this._top=0,this._element=e,this._child=e.children[0],e.parentNode!==t._element&&t._element.appendChild(e),j(e,s.itemClass),"boolean"!=typeof i&&(i="none"!==a(e,"display")),this._isActive=i,e.style.left="0",e.style.top="0",e.style[n]=It(0,0),this._animate=new p(e),this._animateChild=new p(this._child),this._visibility=new zt(this),this._layout=new Ot(this),this._migrate=new Nt(this),this._release=new Ft(this),this._dragPlaceholder=new Gt(this),this._drag=s.dragEnabled?new Xt(this):null,this._refreshDimensions(),this._refreshSortData()}function Qt(){this._slots=[],this._slotSizes=[],this._freeSlots=[],this._newSlots=[],this._rectItem={},this._rectStore=[],this._rectId=0,this._layout={slots:null,setWidth:!1,setHeight:!1,width:!1,height:!1},this._sortRectsLeftTop=this._sortRectsLeftTop.bind(this),this._sortRectsTopLeft=this._sortRectsTopLeft.bind(this)}Kt.prototype.getGrid=function(){return t[this._gridId]},Kt.prototype.getElement=function(){return this._element},Kt.prototype.getWidth=function(){return this._width},Kt.prototype.getHeight=function(){return this._height},Kt.prototype.getMargin=function(){return{left:this._marginLeft,right:this._marginRight,top:this._marginTop,bottom:this._marginBottom}},Kt.prototype.getPosition=function(){return{left:this._left,top:this._top}},Kt.prototype.isActive=function(){return this._isActive},Kt.prototype.isVisible=function(){return!!this._visibility&&!this._visibility._isHidden},Kt.prototype.isShowing=function(){return!(!this._visibility||!this._visibility._isShowing)},Kt.prototype.isHiding=function(){return!(!this._visibility||!this._visibility._isHiding)},Kt.prototype.isPositioning=function(){return!(!this._layout||!this._layout._isActive)},Kt.prototype.isDragging=function(){return!(!this._drag||!this._drag._isActive)},Kt.prototype.isReleasing=function(){return!(!this._release||!this._release._isActive)},Kt.prototype.isDestroyed=function(){return this._isDestroyed},Kt.prototype._refreshDimensions=function(){if(!this._isDestroyed&&!this._visibility._isHidden){var t=this._element,e=this._dragPlaceholder,i=t.getBoundingClientRect();this._width=i.width,this._height=i.height,this._marginLeft=Math.max(0,ht(t,"margin-left")),this._marginRight=Math.max(0,ht(t,"margin-right")),this._marginTop=Math.max(0,ht(t,"margin-top")),this._marginBottom=Math.max(0,ht(t,"margin-bottom")),e&&e.updateDimensions(this._width,this._height)}},Kt.prototype._refreshSortData=function(){if(!this._isDestroyed){var t,e=this._sortData={},i=this.getGrid()._settings.sortData;for(t in i)e[t]=i[t](this,this._element)}},Kt.prototype._destroy=function(t){if(!this._isDestroyed){var e=this._element,i=this.getGrid(),s=i._settings,n=i._items.indexOf(this);this._release.destroy(),this._migrate.destroy(),this._layout.destroy(),this._visibility.destroy(),this._animate.destroy(),this._animateChild.destroy(),this._dragPlaceholder.destroy(),this._drag&&this._drag.destroy(),e.removeAttribute("style"),this._child.removeAttribute("style"),Rt(e,s.itemClass),n>-1&&i._items.splice(n,1),t&&e.parentNode.removeChild(e),this._isActive=!1,this._isDestroyed=!0}},Qt.prototype.getLayout=function(t,e,i,s,n){var r,o=this._layout,h=!(!n||!n.fillGaps),a=!(!n||!n.horizontal),_=!(!n||!n.alignRight),l=!(!n||!n.alignBottom),d=!(!n||!n.rounding),c=this._slotSizes;if(o.slots=s||this._slots,o.width=a?0:d?Math.round(e):e,o.height=a?d?Math.round(i):i:0,o.setWidth=a,o.setHeight=!a,o.slots.length=0,c.length=0,!t.length)return o;for(r=0;r<t.length;r++)this._addSlot(t[r],a,h,d,_||l);if(_)for(r=0;r<o.slots.length;r+=2)o.slots[r]=o.width-(o.slots[r]+c[r]);if(l)for(r=1;r<o.slots.length;r+=2)o.slots[r]=o.height-(o.slots[r]+c[r]);return c.length=0,this._freeSlots.length=0,this._newSlots.length=0,this._rectId=0,o},Qt.prototype._addSlot=(Wt={},function(t,e,i,s,n){var r,o,h,a,_,l,d=this._layout,c=this._freeSlots,u=this._newSlots;for(u.length=0,Wt.left=null,Wt.top=null,Wt.width=t._width+t._marginLeft+t._marginRight,Wt.height=t._height+t._marginTop+t._marginBottom,s&&(Wt.width=Math.round(Wt.width),Wt.height=Math.round(Wt.height)),_=0;_<c.length;_++)if((o=c[_])&&(r=this._getRect(o),Wt.width<=r.width+.001&&Wt.height<=r.height+.001)){Wt.left=r.left,Wt.top=r.top;break}for(null===Wt.left&&(Wt.left=e?d.width:0,Wt.top=e?0:d.height,i||(a=!0)),!e&&Wt.top+Wt.height>d.height&&(Wt.left>0&&u.push(this._addRect(0,d.height,Wt.left,1/0)),Wt.left+Wt.width<d.width&&u.push(this._addRect(Wt.left+Wt.width,d.height,d.width-Wt.left-Wt.width,1/0)),d.height=Wt.top+Wt.height),e&&Wt.left+Wt.width>d.width&&(Wt.top>0&&u.push(this._addRect(d.width,0,1/0,Wt.top)),Wt.top+Wt.height<d.height&&u.push(this._addRect(d.width,Wt.top+Wt.height,1/0,d.height-Wt.top-Wt.height)),d.width=Wt.left+Wt.width),_=i?0:a?c.length:_;_<c.length;_++)if(o=c[_])for(r=this._getRect(o),h=this._splitRect(r,Wt),l=0;l<h.length;l++)o=h[l],(r=this._getRect(o)).width>.49&&r.height>.49&&(!e&&r.top<d.height||e&&r.left<d.width)&&u.push(o);u.length&&this._purgeRects(u).sort(e?this._sortRectsLeftTop:this._sortRectsTopLeft),e?d.width=Math.max(d.width,Wt.left+Wt.width):d.height=Math.max(d.height,Wt.top+Wt.height),d.slots.push(Wt.left,Wt.top),n&&this._slotSizes.push(Wt.width,Wt.height),this._freeSlots=u,this._newSlots=c}),Qt.prototype._addRect=function(t,e,i,s){var n=++this._rectId,r=this._rectStore;return r[n]=t||0,r[++this._rectId]=e||0,r[++this._rectId]=i||0,r[++this._rectId]=s||0,n},Qt.prototype._getRect=function(t,e){var i=e||this._rectItem,s=this._rectStore;return i.left=s[t]||0,i.top=s[++t]||0,i.width=s[++t]||0,i.height=s[++t]||0,i},Qt.prototype._splitRect=(jt=[],function(t,e){return jt.length=0,this._doRectsOverlap(t,e)?(t.left<e.left&&jt.push(this._addRect(t.left,t.top,e.left-t.left,t.height)),t.left+t.width>e.left+e.width&&jt.push(this._addRect(e.left+e.width,t.top,t.left+t.width-(e.left+e.width),t.height)),t.top<e.top&&jt.push(this._addRect(t.left,t.top,t.width,e.top-t.top)),t.top+t.height>e.top+e.height&&jt.push(this._addRect(t.left,e.top+e.height,t.width,t.top+t.height-(e.top+e.height))),jt):(jt.push(this._addRect(t.left,t.top,t.width,t.height)),jt)}),Qt.prototype._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)},Qt.prototype._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},Qt.prototype._purgeRects=(Ut={},Zt={},function(t){for(var e,i=t.length;i--;)if(e=t.length,t[i])for(this._getRect(t[i],Ut);e--;)if(t[e]&&i!==e&&this._isRectWithinRect(Ut,this._getRect(t[e],Zt))){t[i]=0;break}return t}),Qt.prototype._sortRectsTopLeft=function(){var t={},e={};return function(i,s){return this._getRect(i,t),this._getRect(s,e),t.top<e.top?-1:t.top>e.top?1:t.left<e.left?-1:t.left>e.left?1:0}}(),Qt.prototype._sortRectsLeftTop=function(){var t={},e={};return function(i,s){return this._getRect(i,t),this._getRect(s,e),t.left<e.left?-1:t.left>e.left?1:t.top<e.top?-1:t.top>e.top?1:0}}();var te="[object HTMLCollection]",ee="[object NodeList]";function ie(t){var e=Object.prototype.toString.call(t);return e===te||e===ee}var se="object",ne="[object Object]",re=Object.prototype.toString;function oe(t){return typeof t===se&&re.call(t)===ne}function he(t){return ie(t)?Array.prototype.slice.call(t):Array.prototype.concat(t)}var ae=new Qt,_e=function(){},le="number",de="string";function ce(e,s){var n,r,o,h=this;if(!((e=this._element=typeof e===de?window.document.querySelector(e):e).getRootNode?e.getRootNode({composed:!0})===document:window.document.body.contains(e))||e===window.document.documentElement)throw new Error("Container element must be an existing DOM element");c((n=this._settings=function(t,e){var i=ue({},t);e&&(i=ue(i,e));return i.visibleStyles=(e||0).visibleStyles||(t||0).visibleStyles,i.hiddenStyles=(e||0).hiddenStyles||(t||0).hiddenStyles,i}(ce.defaultOptions,s)).dragSort)||(n.dragSort=!!n.dragSort),this._id=Jt(),t[this._id]=h,this._isDestroyed=!1,this._layout={id:0,items:[],slots:[],setWidth:!1,setHeight:!1,width:0,height:0},this._emitter=new i,j(e,n.containerClass),this._items=[],typeof(r=n.items)===de?he(e.children).forEach(function(t){("*"===r||W(t,r))&&h._items.push(new Kt(h,t))}):(Array.isArray(r)||ie(r))&&(this._items=he(r).map(function(t){return new Kt(h,t)})),typeof(o=n.layoutOnResize)!==le&&(o=!0===o?0:-1),o>=0&&window.addEventListener("resize",h._resizeHandler=nt(function(){h.refreshItems().layout()},o)),n.layoutOnInit&&this.layout(!0)}function ue(t,e){var i,s,n,r=Object.keys(e),o=r.length;for(n=0;n<o;n++)i=oe(e[s=r[n]]),oe(t[s])&&i?t[s]=ue(ue({},t[s]),e[s]):i?t[s]=ue({},e[s]):Array.isArray(e[s])?t[s]=e[s].slice(0):t[s]=e[s];return t}return ce.Item=Kt,ce.ItemLayout=Ot,ce.ItemVisibility=zt,ce.ItemMigrate=Nt,ce.ItemAnimate=p,ce.ItemDrag=Xt,ce.ItemRelease=Ft,ce.ItemDragPlaceholder=Gt,ce.Emitter=i,ce.Dragger=M,ce.Packer=Qt,ce.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,dragSortHeuristics:{sortInterval:100,minDragDistance:10,minBounceBackAngle:1},dragSortPredicate:{threshold:50,action:"move"},dragReleaseDuration:300,dragReleaseEasing:"ease",dragCssProps:{touchAction:"none",userSelect:"none",userDrag:"none",tapHighlightColor:"rgba(0, 0, 0, 0)",touchCallout:"none",contentZooming:"none"},dragPlaceholder:{enabled:!1,duration:300,easing:"ease",createElement:null,onCreate:null,onRemove:null},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",itemPlaceholderClass:"muuri-item-placeholder"},ce.prototype.on=function(t,e){return this._emitter.on(t,e),this},ce.prototype.off=function(t,e){return this._emitter.off(t,e),this},ce.prototype.getElement=function(){return this._element},ce.prototype.getItems=function(t){if(this._isDestroyed||!t&&0!==t)return this._items.slice(0);var e,i,s=[],n=he(t);for(i=0;i<n.length;i++)(e=this._getItem(n[i]))&&s.push(e);return s},ce.prototype.refreshItems=function(t){if(this._isDestroyed)return this;var e,i=this.getItems(t);for(e=0;e<i.length;e++)i[e]._refreshDimensions();return this},ce.prototype.refreshSortData=function(t){if(this._isDestroyed)return this;var e,i=this.getItems(t);for(e=0;e<i.length;e++)i[e]._refreshSortData();return this},ce.prototype.synchronize=function(){if(this._isDestroyed)return this;var t,e,i,s=this._element,n=this._items;if(n.length){for(i=0;i<n.length;i++)(e=n[i]._element).parentNode===s&&(t=t||window.document.createDocumentFragment()).appendChild(e);t&&s.appendChild(t)}return this._emit("synchronize"),this},ce.prototype.layout=function(t,i){if(this._isDestroyed)return this;var s,n,r,o=this,h=this._element,_=this._updateLayout(),l=_.id,d=_.items.length,u=d;function f(){if(!(--u>0)){var s=o._layout.id!==l,n=c(t)?t:i;c(n)&&n(s,_.items.slice(0)),!s&&o._hasListeners(e)&&o._emit(e,_.items.slice(0))}}if((_.setHeight&&typeof _.height===le||_.setWidth&&typeof _.width===le)&&(s="border-box"===a(h,"box-sizing")),_.setHeight&&(typeof _.height===le?h.style.height=(s?_.height+this._borderTop+this._borderBottom:_.height)+"px":h.style.height=_.height),_.setWidth&&(typeof _.width===le?h.style.width=(s?_.width+this._borderLeft+this._borderRight:_.width)+"px":h.style.width=_.width),this._hasListeners("layoutStart")&&this._emit("layoutStart",_.items.slice(0)),!d)return f(),this;for(r=0;r<d;r++)(n=_.items[r])&&(n._left=_.slots[2*r],n._top=_.slots[2*r+1],n.isDragging()?f():n._layout.start(!0===t,f));return this},ce.prototype.add=function(t,e){if(this._isDestroyed||!t)return[];var i=he(t);if(!i.length)return i;var s,n,r=e||0,o=r.layout?r.layout:void 0===r.layout,h=this._items,a=!1;for(n=0;n<i.length;n++)s=new Kt(this,i[n],r.isActive),i[n]=s,s._isActive&&(a=!0,s._layout._skipNextAnimation=!0);return $(h,i,r.index),this._hasListeners("add")&&this._emit("add",i.slice(0)),a&&o&&this.layout("instant"===o,c(o)?o:void 0),i},ce.prototype.remove=function(t,e){if(this._isDestroyed)return this;var i,s,n=e||0,r=n.layout?n.layout:void 0===n.layout,o=!1,h=this.getItems(),a=this.getItems(t),_=[];for(s=0;s<a.length;s++)i=a[s],_.push(h.indexOf(i)),i._isActive&&(o=!0),i._destroy(n.removeElements);return this._hasListeners("remove")&&this._emit("remove",a.slice(0),_),o&&r&&this.layout("instant"===r,c(r)?r:void 0),a},ce.prototype.show=function(t,e){return this._isDestroyed?this:(this._setItemsVisibility(t,!0,e),this)},ce.prototype.hide=function(t,e){return this._isDestroyed?this:(this._setItemsVisibility(t,!1,e),this)},ce.prototype.filter=function(t,e){if(this._isDestroyed||!this._items.length)return this;var i,s,n=[],r=[],o=typeof t===de,h=c(t),a=e||0,_=!0===a.instant,l=a.layout?a.layout:void 0===a.layout,d=c(a.onFinish)?a.onFinish:null,u=-1,f=_e;if(d&&(f=function(){++u&&d(n.slice(0),r.slice(0))}),h||o)for(s=0;s<this._items.length;s++)i=this._items[s],(h?t(i):W(i._element,t))?n.push(i):r.push(i);return n.length?this.show(n,{instant:_,onFinish:f,layout:!1}):f(),r.length?this.hide(r,{instant:_,onFinish:f,layout:!1}):f(),(n.length||r.length)&&(this._hasListeners("filter")&&this._emit("filter",n.slice(0),r.slice(0)),l&&this.layout("instant"===l,c(l)?l:void 0)),this},ce.prototype.sort=function(){var t,e,i,s;function n(t){for(var e={},i=0;i<t.length;i++)e[t[i]._id]=i;return e}function r(t,i){var n=s[t._id],r=s[i._id];return e?r-n:n-r}function o(o,h){for(var a,_,l,d,c=0,u=0;u<t.length;u++)if(a=t[u][0],_=t[u][1],l=(o._sortData?o:o._refreshSortData())._sortData[a],d=(h._sortData?h:h._refreshSortData())._sortData[a],c="desc"===_||!_&&e?d<l?-1:d>l?1:0:l<d?-1:l>d?1:0)return c;return c||(s||(s=n(i)),c=r(o,h)),c}function h(o,h){var a=t(o,h);return e&&a&&(a=-a),a||(s||(s=n(i)),r(o,h))}return function(n,r){if(this._isDestroyed||this._items.length<2)return this;var a,_=this._items,l=r||0,d=l.layout?l.layout:void 0===l.layout;if(t=n,e=!!l.descending,i=_.slice(0),s=null,c(t))_.sort(h);else if(typeof t===de)t=n.trim().split(" ").map(function(t){return t.split(":")}),_.sort(o);else{if(!Array.isArray(t))return this;if(t.length!==_.length)throw new Error("[Muuri] sort reference items do not match with grid items.");for(a=0;a<_.length;a++){if(t.indexOf(_[a])<0)throw new Error("[Muuri] sort reference items do not match with grid items.");_[a]=t[a]}e&&_.reverse()}return this._hasListeners("sort")&&this._emit("sort",_.slice(0),i),d&&this.layout("instant"===d,c(d)?d:void 0),this}}(),ce.prototype.move=function(t,e,i){if(this._isDestroyed||this._items.length<2)return this;var s,n,r=this._items,o=i||0,h=o.layout?o.layout:void 0===o.layout,a="swap"===o.action,_=a?"swap":"move",l=this._getItem(t),d=this._getItem(e);return l&&d&&l!==d&&(s=r.indexOf(l),n=r.indexOf(d),a?Q(r,s,n):K(r,s,n),this._hasListeners("move")&&this._emit("move",{item:l,fromIndex:s,toIndex:n,action:_}),h&&this.layout("instant"===h,c(h)?h:void 0)),this},ce.prototype.send=function(t,e,i,s){if(this._isDestroyed||e._isDestroyed||this===e)return this;if(!(t=this._getItem(t)))return this;var n=s||0,r=n.appendTo||window.document.body,o=n.layoutSender?n.layoutSender:void 0===n.layoutSender,h=n.layoutReceiver?n.layoutReceiver:void 0===n.layoutReceiver;return t._migrate.start(e,i,r),t._migrate._isActive&&t._isActive&&(o&&this.layout("instant"===o,c(o)?o:void 0),h&&e.layout("instant"===h,c(h)?h:void 0)),this},ce.prototype.destroy=function(e){if(this._isDestroyed)return this;var i,s=this._element,n=this._items.slice(0);for(this._resizeHandler&&window.removeEventListener("resize",this._resizeHandler),i=0;i<n.length;i++)n[i]._destroy(e);return Rt(s,this._settings.containerClass),s.style.height="",s.style.width="",this._emit("destroy"),this._emitter.destroy(),t[this._id]=void 0,this._isDestroyed=!0,this},ce.prototype._getItem=function(t){if(this._isDestroyed||!t&&0!==t)return null;if(typeof t===le)return this._items[t>-1?t:this._items.length+t]||null;if(t instanceof Kt)return t._gridId===this._id?t:null;for(var e=0;e<this._items.length;e++)if(this._items[e]._element===t)return this._items[e];return null},ce.prototype._updateLayout=function(){var t,e,i,s,n=this._layout,r=this._settings.layout;for(++n.id,n.items.length=0,s=0;s<this._items.length;s++)this._items[s]._isActive&&n.items.push(this._items[s]);return this._refreshDimensions(),t=this._width-this._borderLeft-this._borderRight,e=this._height-this._borderTop-this._borderBottom,i=c(r)?r(n.items,t,e):ae.getLayout(n.items,t,e,n.slots,r),n.slots=i.slots,n.setWidth=Boolean(i.setWidth),n.setHeight=Boolean(i.setHeight),n.width=i.width,n.height=i.height,n},ce.prototype._emit=function(){this._isDestroyed||this._emitter.emit.apply(this._emitter,arguments)},ce.prototype._hasListeners=function(t){var e=this._emitter._events[t];return!(!e||!e.length)},ce.prototype._updateBoundingRect=function(){var t=this._element.getBoundingClientRect();this._width=t.width,this._height=t.height,this._left=t.left,this._top=t.top},ce.prototype._updateBorders=function(t,e,i,s){var n=this._element;t&&(this._borderLeft=ht(n,"border-left-width")),e&&(this._borderRight=ht(n,"border-right-width")),i&&(this._borderTop=ht(n,"border-top-width")),s&&(this._borderBottom=ht(n,"border-bottom-width"))},ce.prototype._refreshDimensions=function(){this._updateBoundingRect(),this._updateBorders(1,1,1,1)},ce.prototype._setItemsVisibility=function(t,e,i){var s,n,r=this,o=this.getItems(t),h=i||0,a=!0===h.instant,_=h.onFinish,l=h.layout?h.layout:void 0===h.layout,d=o.length,u=e?"showStart":"hideStart",f=e?"showEnd":"hideEnd",p=e?"show":"hide",m=!1,g=[],y=[];if(d){for(this._hasListeners(u)&&this._emit(u,o.slice(0)),n=0;n<o.length;n++)s=o[n],(e&&!s._isActive||!e&&s._isActive)&&(m=!0),e&&!s._isActive&&(s._layout._skipNextAnimation=!0),e&&s._visibility._isHidden&&y.push(s),s._visibility[p](a,function(t,e){t||g.push(e),--d<1&&(c(_)&&_(g.slice(0)),r._hasListeners(f)&&r._emit(f,g.slice(0)))});y.length&&this.refreshItems(y),m&&l&&this.layout("instant"===l,c(l)?l:void 0)}else c(_)&&_(o)},ce}); |
@@ -9,3 +9,2 @@ const fs = require('fs'); | ||
const dotenv = require('dotenv'); | ||
const replace = require('gulp-replace'); | ||
const exec = require('child_process').exec; | ||
@@ -16,15 +15,4 @@ | ||
const patchedUMD = `(function (global, factory) { | ||
if (typeof exports === 'object' && typeof module !== 'undefined') { | ||
var Hammer; | ||
try { Hammer = require('hammerjs') } catch (e) {} | ||
module.exports = factory(Hammer); | ||
} else { | ||
global.Muuri = factory(global.Hammer); | ||
} | ||
}(this, (function (Hammer) { | ||
'use strict';`; | ||
if (fs.existsSync('./.env')) dotenv.config(); | ||
if (fs.existsSync('./.env')) dotenv.load(); | ||
gulp.task('lint', () => { | ||
@@ -182,10 +170,2 @@ return gulp | ||
gulp.task('fix-umd', () => { | ||
const mainPath = './' + pkg.main; | ||
return gulp | ||
.src(mainPath, { base: './' }) | ||
.pipe(replace(/\(function([\s\S]*?)Hammer;/, patchedUMD)) | ||
.pipe(gulp.dest('./')); | ||
}); | ||
gulp.task('minify', cb => { | ||
@@ -201,3 +181,3 @@ exec('npm run minify', (err, stdout, stderr) => { | ||
'build', | ||
gulp.series('bundle', 'fix-umd', 'minify', done => { | ||
gulp.series('bundle', 'minify', done => { | ||
done(); | ||
@@ -204,0 +184,0 @@ }) |
@@ -16,3 +16,2 @@ const pkg = require('./package.json'); | ||
files: [ | ||
'./node_modules/hammerjs/hammer.js', | ||
'./node_modules/web-animations-js/web-animations.min.js', | ||
@@ -36,7 +35,3 @@ './node_modules/prosthetic-hand/dist/prosthetic-hand.js', | ||
autoWatch: false, | ||
captureTimeout: 240000, | ||
browserDisconnectTimeout: 60000, | ||
browserNoActivityTimeout: 60000, | ||
browserDisconnectTolerance: 10, | ||
concurrency: 1, | ||
browserDisconnectTolerance: 2, | ||
singleRun: true, | ||
@@ -43,0 +38,0 @@ hostname: '127.0.0.1', |
{ | ||
"name": "muuri", | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"description": "Responsive, sortable, filterable and draggable grid layouts.", | ||
@@ -45,34 +45,26 @@ "keywords": [ | ||
}, | ||
"peerDependencies": { | ||
"hammerjs": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"dotenv": "^6.0.0", | ||
"gulp": "^4.0.0", | ||
"gulp-eslint": "^5.0.0", | ||
"gulp-replace": "^1.0.0", | ||
"dotenv": "^8.0.0", | ||
"gulp": "^4.0.2", | ||
"gulp-eslint": "^6.0.0", | ||
"gulp-size": "^3.0.0", | ||
"hammerjs": "^2.0.8", | ||
"husky": "^1.0.0-rc.13", | ||
"karma": "^3.0.0", | ||
"husky": "^1.3.1", | ||
"karma": "^4.1.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-edge-launcher": "^0.4.2", | ||
"karma-firefox-launcher": "^1.1.0", | ||
"karma-qunit": "^2.1.0", | ||
"karma-qunit": "^3.1.2", | ||
"karma-safari-launcher": "^1.0.0", | ||
"karma-sauce-launcher": "^1.2.0", | ||
"karma-sauce-launcher": "^2.0.2", | ||
"karma-story-reporter": "^0.3.1", | ||
"mezr": "^0.6.2", | ||
"prettier": "^1.14.3", | ||
"prettier": "^1.18.2", | ||
"prosthetic-hand": "^1.3.1", | ||
"qunit": "^2.6.2", | ||
"rimraf": "^2.6.2", | ||
"rollup": "^0.66.1", | ||
"rollup-plugin-commonjs": "^9.1.8", | ||
"rollup-plugin-node-resolve": "^3.4.0", | ||
"rollup-plugin-strip-banner": "^0.2.0", | ||
"terser": "^3.8.2", | ||
"web-animations-js": "^2.3.1", | ||
"yargs": "^12.0.2" | ||
"qunit": "^2.9.2", | ||
"rimraf": "^2.6.3", | ||
"rollup": "^1.16.7", | ||
"terser": "^4.1.2", | ||
"web-animations-js": "^2.3.2", | ||
"yargs": "^13.2.4" | ||
} | ||
} |
@@ -1,37 +0,22 @@ | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import stripBanner from 'rollup-plugin-strip-banner'; | ||
import pkg from './package.json'; | ||
const pkg = require('./package.json'); | ||
const banner = require('./rollup.banner.js'); | ||
const banner = `/** | ||
* Muuri v${pkg.version} | ||
* ${pkg.homepage} | ||
* Copyright (c) 2015-present, Haltu Oy | ||
* Released under the MIT license | ||
* https://github.com/haltu/muuri/blob/master/LICENSE.md | ||
* @license MIT | ||
* | ||
* Muuri Packer | ||
* Copyright (c) 2016-present, Niklas Rämö <inramo@gmail.com> | ||
* @license MIT | ||
* | ||
* Muuri Ticker / Muuri Emitter / Muuri Queue | ||
* Copyright (c) 2018-present, Niklas Rämö <inramo@gmail.com> | ||
* @license MIT | ||
*/ | ||
`; | ||
const stripBanner = { | ||
transform(code) { | ||
return { | ||
code: code.replace(/\/\*\*([\s\S]*?)\*\//, ''), | ||
map: { mappings: '' } | ||
}; | ||
} | ||
}; | ||
export default [ | ||
{ | ||
external: ['hammerjs'], | ||
input: 'src/index.js', | ||
output: { | ||
name: 'Muuri', | ||
file: pkg.main, | ||
format: 'umd', | ||
globals: { hammerjs: 'Hammer' }, | ||
banner: banner | ||
}, | ||
plugins: [resolve(), commonjs(), stripBanner()] | ||
} | ||
]; | ||
module.exports = { | ||
input: 'src/index.js', | ||
output: { | ||
name: 'Muuri', | ||
file: pkg.main, | ||
format: 'umd', | ||
banner: banner | ||
}, | ||
plugins: [stripBanner] | ||
}; |
@@ -48,22 +48,2 @@ /** | ||
/** | ||
* Bind an event listener that is triggered only once. | ||
* | ||
* @public | ||
* @memberof Emitter.prototype | ||
* @param {String} event | ||
* @param {Function} listener | ||
* @returns {Emitter} | ||
*/ | ||
Emitter.prototype.once = function(event, listener) { | ||
if (this._isDestroyed) return this; | ||
var callback = function() { | ||
this.off(event, callback); | ||
listener.apply(null, arguments); | ||
}.bind(this); | ||
return this.on(event, callback); | ||
}; | ||
/** | ||
* Unbind all event listeners that match the provided listener function. | ||
@@ -70,0 +50,0 @@ * |
@@ -8,2 +8,4 @@ /** | ||
import { | ||
actionMove, | ||
actionSwap, | ||
eventSynchronize, | ||
@@ -24,27 +26,30 @@ eventLayoutStart, | ||
namespace | ||
} from '../shared.js'; | ||
} from '../shared'; | ||
import Emitter from '../Emitter/Emitter.js'; | ||
import Item from '../Item/Item.js'; | ||
import ItemAnimate from '../Item/ItemAnimate.js'; | ||
import ItemDrag from '../Item/ItemDrag.js'; | ||
import ItemLayout from '../Item/ItemLayout.js'; | ||
import ItemMigrate from '../Item/ItemMigrate.js'; | ||
import ItemRelease from '../Item/ItemRelease.js'; | ||
import ItemVisibility from '../Item/ItemVisibility.js'; | ||
import Packer from '../Packer/Packer.js'; | ||
import Emitter from '../Emitter/Emitter'; | ||
import Item from '../Item/Item'; | ||
import ItemAnimate from '../Item/ItemAnimate'; | ||
import ItemDrag from '../Item/ItemDrag'; | ||
import ItemDragPlaceholder from '../Item/ItemDragPlaceholder'; | ||
import ItemLayout from '../Item/ItemLayout'; | ||
import ItemMigrate from '../Item/ItemMigrate'; | ||
import ItemRelease from '../Item/ItemRelease'; | ||
import ItemVisibility from '../Item/ItemVisibility'; | ||
import Packer from '../Packer/Packer'; | ||
import Dragger from '../Dragger/Dragger'; | ||
import addClass from '../utils/addClass.js'; | ||
import arrayMove from '../utils/arrayMove.js'; | ||
import arraySwap from '../utils/arraySwap.js'; | ||
import createUid from '../utils/createUid.js'; | ||
import debounce from '../utils/debounce.js'; | ||
import elementMatches from '../utils/elementMatches.js'; | ||
import getStyle from '../utils/getStyle.js'; | ||
import getStyleAsFloat from '../utils/getStyleAsFloat.js'; | ||
import arrayInsert from '../utils/arrayInsert.js'; | ||
import isNodeList from '../utils/isNodeList.js'; | ||
import isPlainObject from '../utils/isPlainObject.js'; | ||
import removeClass from '../utils/removeClass.js'; | ||
import toArray from '../utils/toArray.js'; | ||
import addClass from '../utils/addClass'; | ||
import arrayMove from '../utils/arrayMove'; | ||
import arraySwap from '../utils/arraySwap'; | ||
import createUid from '../utils/createUid'; | ||
import debounce from '../utils/debounce'; | ||
import elementMatches from '../utils/elementMatches'; | ||
import getStyle from '../utils/getStyle'; | ||
import getStyleAsFloat from '../utils/getStyleAsFloat'; | ||
import arrayInsert from '../utils/arrayInsert'; | ||
import isFunction from '../utils/isFunction'; | ||
import isNodeList from '../utils/isNodeList'; | ||
import isPlainObject from '../utils/isPlainObject'; | ||
import removeClass from '../utils/removeClass'; | ||
import toArray from '../utils/toArray'; | ||
@@ -54,2 +59,6 @@ var packer = new Packer(); | ||
var numberType = 'number'; | ||
var stringType = 'string'; | ||
var instantLayout = 'instant'; | ||
/** | ||
@@ -61,3 +70,3 @@ * Creates a new Grid instance. | ||
* @param {Object} [options] | ||
* @param {(?HTMLElement[]|NodeList|String)} [options.items] | ||
* @param {?(HTMLElement[]|NodeList|String)} [options.items] | ||
* @param {Number} [options.showDuration=300] | ||
@@ -88,3 +97,6 @@ * @param {String} [options.showEasing="ease"] | ||
* @param {(Boolean|Function)} [options.dragSort=true] | ||
* @param {Number} [options.dragSortInterval=100] | ||
* @param {Object} [options.dragSortHeuristics] | ||
* @param {Number} [options.dragSortHeuristics.sortInterval=100] | ||
* @param {Number} [options.dragSortHeuristics.minDragDistance=10] | ||
* @param {Number} [options.dragSortHeuristics.minBounceBackAngle=1] | ||
* @param {(Function|Object)} [options.dragSortPredicate] | ||
@@ -95,3 +107,10 @@ * @param {Number} [options.dragSortPredicate.threshold=50] | ||
* @param {String} [options.dragReleaseEasing="ease"] | ||
* @param {Object} [options.dragHammerSettings={touchAction: "none"}] | ||
* @param {Object} [options.dragCssProps] | ||
* @param {Object} [options.dragPlaceholder] | ||
* @param {Boolean} [options.dragPlaceholder.enabled=false] | ||
* @param {Number} [options.dragPlaceholder.duration=300] | ||
* @param {String} [options.dragPlaceholder.easing="ease"] | ||
* @param {?Function} [options.dragPlaceholder.createElement=null] | ||
* @param {?Function} [options.dragPlaceholder.onCreate=null] | ||
* @param {?Function} [options.dragPlaceholder.onRemove=null] | ||
* @param {String} [options.containerClass="muuri"] | ||
@@ -104,3 +123,5 @@ * @param {String} [options.itemClass="muuri-item"] | ||
* @param {String} [options.itemReleasingClass="muuri-item-releasing"] | ||
* @param {String} [options.itemPlaceholderClass="muuri-item-placeholder"] | ||
*/ | ||
function Grid(element, options) { | ||
@@ -113,7 +134,11 @@ var inst = this; | ||
// Allow passing element as selector string. Store element for instance. | ||
element = this._element = typeof element === 'string' ? document.querySelector(element) : element; | ||
element = this._element = | ||
typeof element === stringType ? window.document.querySelector(element) : element; | ||
// Throw an error if the container element is not body element or does not | ||
// exist within the body element. | ||
if (!document.body.contains(element)) { | ||
var isElementInDom = element.getRootNode | ||
? element.getRootNode({ composed: true }) === document | ||
: window.document.body.contains(element); | ||
if (!isElementInDom || element === window.document.documentElement) { | ||
throw new Error('Container element must be an existing DOM element'); | ||
@@ -126,3 +151,3 @@ } | ||
// Sanitize dragSort setting. | ||
if (typeof settings.dragSort !== 'function') { | ||
if (!isFunction(settings.dragSort)) { | ||
settings.dragSort = !!settings.dragSort; | ||
@@ -158,3 +183,3 @@ } | ||
items = settings.items; | ||
if (typeof items === 'string') { | ||
if (typeof items === stringType) { | ||
toArray(element.children).forEach(function(itemElement) { | ||
@@ -174,3 +199,3 @@ if (items === '*' || elementMatches(itemElement, items)) { | ||
layoutOnResize = settings.layoutOnResize; | ||
if (typeof layoutOnResize !== 'number') { | ||
if (typeof layoutOnResize !== numberType) { | ||
layoutOnResize = layoutOnResize === true ? 0 : -1; | ||
@@ -214,7 +239,2 @@ } | ||
/** | ||
* @see ItemRelease | ||
*/ | ||
Grid.ItemRelease = ItemRelease; | ||
/** | ||
* @see ItemMigrate | ||
@@ -235,2 +255,12 @@ */ | ||
/** | ||
* @see ItemRelease | ||
*/ | ||
Grid.ItemRelease = ItemRelease; | ||
/** | ||
* @see ItemDragPlaceholder | ||
*/ | ||
Grid.ItemDragPlaceholder = ItemDragPlaceholder; | ||
/** | ||
* @see Emitter | ||
@@ -241,2 +271,12 @@ */ | ||
/** | ||
* @see Dragger | ||
*/ | ||
Grid.Dragger = Dragger; | ||
/** | ||
* @see Packer | ||
*/ | ||
Grid.Packer = Packer; | ||
/** | ||
* Default options for Grid instance. | ||
@@ -295,12 +335,29 @@ * | ||
dragSort: true, | ||
dragSortInterval: 100, | ||
dragSortHeuristics: { | ||
sortInterval: 100, | ||
minDragDistance: 10, | ||
minBounceBackAngle: 1 | ||
}, | ||
dragSortPredicate: { | ||
threshold: 50, | ||
action: 'move' | ||
action: actionMove | ||
}, | ||
dragReleaseDuration: 300, | ||
dragReleaseEasing: 'ease', | ||
dragHammerSettings: { | ||
touchAction: 'none' | ||
dragCssProps: { | ||
touchAction: 'none', | ||
userSelect: 'none', | ||
userDrag: 'none', | ||
tapHighlightColor: 'rgba(0, 0, 0, 0)', | ||
touchCallout: 'none', | ||
contentZooming: 'none' | ||
}, | ||
dragPlaceholder: { | ||
enabled: false, | ||
duration: 300, | ||
easing: 'ease', | ||
createElement: null, | ||
onCreate: null, | ||
onRemove: null | ||
}, | ||
@@ -314,3 +371,4 @@ // Classnames | ||
itemDraggingClass: 'muuri-item-dragging', | ||
itemReleasingClass: 'muuri-item-releasing' | ||
itemReleasingClass: 'muuri-item-releasing', | ||
itemPlaceholderClass: 'muuri-item-placeholder' | ||
}; | ||
@@ -338,16 +396,2 @@ | ||
/** | ||
* Bind an event listener that is triggered only once. | ||
* | ||
* @public | ||
* @memberof Grid.prototype | ||
* @param {String} event | ||
* @param {Function} listener | ||
* @returns {Grid} | ||
*/ | ||
Grid.prototype.once = function(event, listener) { | ||
this._emitter.once(event, listener); | ||
return this; | ||
}; | ||
/** | ||
* Unbind an event listener. | ||
@@ -476,3 +520,3 @@ * | ||
if (element.parentNode === container) { | ||
fragment = fragment || document.createDocumentFragment(); | ||
fragment = fragment || window.document.createDocumentFragment(); | ||
fragment.appendChild(element); | ||
@@ -509,5 +553,2 @@ } | ||
var counter = itemsLength; | ||
var callback = typeof instant === 'function' ? instant : onFinish; | ||
var isCallbackFunction = typeof callback === 'function'; | ||
var callbackItems = isCallbackFunction ? layout.items.slice(0) : null; | ||
var isBorderBox; | ||
@@ -523,4 +564,10 @@ var item; | ||
if (--counter > 0) return; | ||
var hasLayoutChanged = inst._layout.id !== layoutId; | ||
isCallbackFunction && callback(hasLayoutChanged, callbackItems); | ||
var callback = isFunction(instant) ? instant : onFinish; | ||
if (isFunction(callback)) { | ||
callback(hasLayoutChanged, layout.items.slice(0)); | ||
} | ||
if (!hasLayoutChanged && inst._hasListeners(eventLayoutEnd)) { | ||
@@ -535,6 +582,8 @@ inst._emit(eventLayoutEnd, layout.items.slice(0)); | ||
// therefore we need to add the grid element's borders to the dimensions if | ||
// it's box-sizing is border-box. | ||
// it's box-sizing is border-box. Note that we support providing the | ||
// dimensions as a string here too so that one can define the unit of the | ||
// dimensions, in which case we don't do the border-box check. | ||
if ( | ||
(layout.setHeight && typeof layout.height === 'number') || | ||
(layout.setWidth && typeof layout.width === 'number') | ||
(layout.setHeight && typeof layout.height === numberType) || | ||
(layout.setWidth && typeof layout.width === numberType) | ||
) { | ||
@@ -544,3 +593,3 @@ isBorderBox = getStyle(element, 'box-sizing') === 'border-box'; | ||
if (layout.setHeight) { | ||
if (typeof layout.height === 'number') { | ||
if (typeof layout.height === numberType) { | ||
element.style.height = | ||
@@ -553,3 +602,3 @@ (isBorderBox ? layout.height + this._borderTop + this._borderBottom : layout.height) + 'px'; | ||
if (layout.setWidth) { | ||
if (typeof layout.width === 'number') { | ||
if (typeof layout.width === numberType) { | ||
element.style.width = | ||
@@ -652,3 +701,3 @@ (isBorderBox ? layout.width + this._borderLeft + this._borderRight : layout.width) + 'px'; | ||
if (needsLayout && layout) { | ||
this.layout(layout === 'instant', typeof layout === 'function' ? layout : undefined); | ||
this.layout(layout === instantLayout, isFunction(layout) ? layout : undefined); | ||
} | ||
@@ -697,3 +746,3 @@ | ||
if (needsLayout && layout) { | ||
this.layout(layout === 'instant', typeof layout === 'function' ? layout : undefined); | ||
this.layout(layout === instantLayout, isFunction(layout) ? layout : undefined); | ||
} | ||
@@ -764,8 +813,8 @@ | ||
var itemsToHide = []; | ||
var isPredicateString = typeof predicate === 'string'; | ||
var isPredicateFn = typeof predicate === 'function'; | ||
var isPredicateString = typeof predicate === stringType; | ||
var isPredicateFn = isFunction(predicate); | ||
var opts = options || 0; | ||
var isInstant = opts.instant === true; | ||
var layout = opts.layout ? opts.layout : opts.layout === undefined; | ||
var onFinish = typeof opts.onFinish === 'function' ? opts.onFinish : null; | ||
var onFinish = isFunction(opts.onFinish) ? opts.onFinish : null; | ||
var tryFinishCounter = -1; | ||
@@ -826,3 +875,3 @@ var tryFinish = noop; | ||
if (layout) { | ||
this.layout(layout === 'instant', typeof layout === 'function' ? layout : undefined); | ||
this.layout(layout === instantLayout, isFunction(layout) ? layout : undefined); | ||
} | ||
@@ -947,3 +996,3 @@ } | ||
// If function is provided do a native array sort. | ||
if (typeof sortComparer === 'function') { | ||
if (isFunction(sortComparer)) { | ||
items.sort(customComparer); | ||
@@ -953,3 +1002,3 @@ } | ||
// the instance's options. | ||
else if (typeof sortComparer === 'string') { | ||
else if (typeof sortComparer === stringType) { | ||
sortComparer = parseCriteria(comparer); | ||
@@ -985,3 +1034,3 @@ items.sort(defaultComparer); | ||
if (layout) { | ||
this.layout(layout === 'instant', typeof layout === 'function' ? layout : undefined); | ||
this.layout(layout === instantLayout, isFunction(layout) ? layout : undefined); | ||
} | ||
@@ -1014,4 +1063,4 @@ | ||
var layout = opts.layout ? opts.layout : opts.layout === undefined; | ||
var isSwap = opts.action === 'swap'; | ||
var action = isSwap ? 'swap' : 'move'; | ||
var isSwap = opts.action === actionSwap; | ||
var action = isSwap ? actionSwap : actionMove; | ||
var fromItem = this._getItem(item); | ||
@@ -1047,3 +1096,3 @@ var toItem = this._getItem(position); | ||
if (layout) { | ||
this.layout(layout === 'instant', typeof layout === 'function' ? layout : undefined); | ||
this.layout(layout === instantLayout, isFunction(layout) ? layout : undefined); | ||
} | ||
@@ -1077,3 +1126,3 @@ } | ||
var opts = options || 0; | ||
var container = opts.appendTo || document.body; | ||
var container = opts.appendTo || window.document.body; | ||
var layoutSender = opts.layoutSender ? opts.layoutSender : opts.layoutSender === undefined; | ||
@@ -1092,4 +1141,4 @@ var layoutReceiver = opts.layoutReceiver | ||
this.layout( | ||
layoutSender === 'instant', | ||
typeof layoutSender === 'function' ? layoutSender : undefined | ||
layoutSender === instantLayout, | ||
isFunction(layoutSender) ? layoutSender : undefined | ||
); | ||
@@ -1099,4 +1148,4 @@ } | ||
grid.layout( | ||
layoutReceiver === 'instant', | ||
typeof layoutReceiver === 'function' ? layoutReceiver : undefined | ||
layoutReceiver === instantLayout, | ||
isFunction(layoutReceiver) ? layoutReceiver : undefined | ||
); | ||
@@ -1177,3 +1226,3 @@ } | ||
// example -1 for the last item, -2 for the second last item, etc. | ||
if (typeof target === 'number') { | ||
if (typeof target === numberType) { | ||
return this._items[target > -1 ? target : this._items.length + target] || null; | ||
@@ -1233,3 +1282,3 @@ } | ||
// Calculate new layout. | ||
if (typeof settings === 'function') { | ||
if (isFunction(settings)) { | ||
newLayout = settings(layout.items, width, height); | ||
@@ -1351,3 +1400,3 @@ } else { | ||
if (!counter) { | ||
if (typeof callback === 'function') callback(targetItems); | ||
if (isFunction(callback)) callback(targetItems); | ||
return; | ||
@@ -1392,3 +1441,3 @@ } | ||
if (--counter < 1) { | ||
if (typeof callback === 'function') callback(completedItems.slice(0)); | ||
if (isFunction(callback)) callback(completedItems.slice(0)); | ||
if (grid._hasListeners(endEvent)) grid._emit(endEvent, completedItems.slice(0)); | ||
@@ -1404,3 +1453,3 @@ } | ||
if (needsLayout && layout) { | ||
this.layout(layout === 'instant', typeof layout === 'function' ? layout : undefined); | ||
this.layout(layout === instantLayout, isFunction(layout) ? layout : undefined); | ||
} | ||
@@ -1407,0 +1456,0 @@ }; |
@@ -7,3 +7,3 @@ /** | ||
import Grid from './Grid/Grid.js'; | ||
import Grid from './Grid/Grid'; | ||
export default Grid; |
@@ -7,18 +7,19 @@ /** | ||
import { gridInstances } from '../shared.js'; | ||
import { gridInstances } from '../shared'; | ||
import ItemAnimate from './ItemAnimate.js'; | ||
import ItemDrag from './ItemDrag.js'; | ||
import ItemLayout from './ItemLayout.js'; | ||
import ItemMigrate from './ItemMigrate.js'; | ||
import ItemRelease from './ItemRelease.js'; | ||
import ItemVisibility from './ItemVisibility.js'; | ||
import ItemAnimate from './ItemAnimate'; | ||
import ItemDrag from './ItemDrag'; | ||
import ItemDragPlaceholder from './ItemDragPlaceholder'; | ||
import ItemLayout from './ItemLayout'; | ||
import ItemMigrate from './ItemMigrate'; | ||
import ItemRelease from './ItemRelease'; | ||
import ItemVisibility from './ItemVisibility'; | ||
import addClass from '../utils/addClass.js'; | ||
import createUid from '../utils/createUid.js'; | ||
import getStyle from '../utils/getStyle.js'; | ||
import getStyleAsFloat from '../utils/getStyleAsFloat.js'; | ||
import getTranslateString from '../utils/getTranslateString.js'; | ||
import removeClass from '../utils/removeClass.js'; | ||
import { transformProp } from '../utils/supportedTransform.js'; | ||
import addClass from '../utils/addClass'; | ||
import createUid from '../utils/createUid'; | ||
import getStyle from '../utils/getStyle'; | ||
import getStyleAsFloat from '../utils/getStyleAsFloat'; | ||
import getTranslateString from '../utils/getTranslateString'; | ||
import removeClass from '../utils/removeClass'; | ||
import { transformProp } from '../utils/supportedTransform'; | ||
@@ -89,5 +90,12 @@ /** | ||
// Set up release handler | ||
// Set up release handler. Note that although this is fully linked to dragging | ||
// this still needs to be always instantiated to handle migration scenarios | ||
// correctly. | ||
this._release = new ItemRelease(this); | ||
// Set up drag placeholder handler. Note that although this is fully linked to | ||
// dragging this still needs to be always instantiated to handle migration | ||
// scenarios correctly. | ||
this._dragPlaceholder = new ItemDragPlaceholder(this); | ||
// Set up drag handler. | ||
@@ -287,2 +295,3 @@ this._drag = settings.dragEnabled ? new ItemDrag(this) : null; | ||
var element = this._element; | ||
var dragPlaceholder = this._dragPlaceholder; | ||
var rect = element.getBoundingClientRect(); | ||
@@ -299,2 +308,7 @@ | ||
this._marginBottom = Math.max(0, getStyleAsFloat(element, 'margin-bottom')); | ||
// Keep drag placeholder's dimensions synced with the item's. | ||
if (dragPlaceholder) { | ||
dragPlaceholder.updateDimensions(this._width, this._height); | ||
} | ||
}; | ||
@@ -342,2 +356,3 @@ | ||
this._animateChild.destroy(); | ||
this._dragPlaceholder.destroy(); | ||
this._drag && this._drag.destroy(); | ||
@@ -344,0 +359,0 @@ |
@@ -7,6 +7,7 @@ /** | ||
import getStyle from '../utils/getStyle.js'; | ||
import getStyleName from '../utils/getStyleName.js'; | ||
import setStyles from '../utils/setStyles.js'; | ||
import { transformProp } from '../utils/supportedTransform.js'; | ||
import getStyle from '../utils/getStyle'; | ||
import getStyleName from '../utils/getStyleName'; | ||
import isFunction from '../utils/isFunction'; | ||
import setStyles from '../utils/setStyles'; | ||
import { transformProp } from '../utils/supportedTransform'; | ||
@@ -88,3 +89,3 @@ /** | ||
// Store animation callback. | ||
this._callback = typeof opts.onFinish === 'function' ? opts.onFinish : null; | ||
this._callback = isFunction(opts.onFinish) ? opts.onFinish : null; | ||
@@ -91,0 +92,0 @@ // If we have a running animation that does not need to be cancelled, let's |
@@ -7,5 +7,5 @@ /** | ||
import Hammer from 'hammerjs'; | ||
import { | ||
actionMove, | ||
actionSwap, | ||
eventMove, | ||
@@ -21,30 +21,26 @@ eventSend, | ||
eventDragEnd, | ||
gridInstances, | ||
namespace | ||
} from '../shared.js'; | ||
gridInstances | ||
} from '../shared'; | ||
import { addMoveTick, cancelMoveTick, addScrollTick, cancelScrollTick } from '../ticker.js'; | ||
import Dragger from '../Dragger/Dragger'; | ||
import addClass from '../utils/addClass.js'; | ||
import arrayMove from '../utils/arrayMove.js'; | ||
import arraySwap from '../utils/arraySwap.js'; | ||
import debounce from '../utils/debounce.js'; | ||
import elementMatches from '../utils/elementMatches.js'; | ||
import getContainingBlock from '../utils/getContainingBlock.js'; | ||
import getOffsetDiff from '../utils/getOffsetDiff.js'; | ||
import getStyle from '../utils/getStyle.js'; | ||
import getTranslate from '../utils/getTranslate.js'; | ||
import getTranslateString from '../utils/getTranslateString.js'; | ||
import arrayInsert from '../utils/arrayInsert.js'; | ||
import isPlainObject from '../utils/isPlainObject.js'; | ||
import isTransformed from '../utils/isTransformed.js'; | ||
import normalizeArrayIndex from '../utils/normalizeArrayIndex.js'; | ||
import removeClass from '../utils/removeClass.js'; | ||
import { addMoveTick, cancelMoveTick, addScrollTick, cancelScrollTick } from '../ticker'; | ||
import addClass from '../utils/addClass'; | ||
import arrayInsert from '../utils/arrayInsert'; | ||
import arrayMove from '../utils/arrayMove'; | ||
import arraySwap from '../utils/arraySwap'; | ||
import debounce from '../utils/debounce'; | ||
import elementMatches from '../utils/elementMatches'; | ||
import getContainingBlock from '../utils/getContainingBlock'; | ||
import getOffsetDiff from '../utils/getOffsetDiff'; | ||
import getScrollableAncestors from '../utils/getScrollableAncestors'; | ||
import getTranslate from '../utils/getTranslate'; | ||
import getTranslateString from '../utils/getTranslateString'; | ||
import isFunction from '../utils/isFunction'; | ||
import normalizeArrayIndex from '../utils/normalizeArrayIndex'; | ||
import removeClass from '../utils/removeClass'; | ||
import setStyles from '../utils/setStyles'; | ||
import { isTransformSupported, transformProp } from '../utils/supportedTransform.js'; | ||
import { transformProp } from '../utils/supportedTransform'; | ||
// To provide consistently correct dragging experience we need to know if | ||
// transformed elements leak fixed elements or not. | ||
var hasTransformLeak = checkTransformLeak(); | ||
// Drag start predicate states. | ||
@@ -57,3 +53,3 @@ var startPredicateInactive = 0; | ||
/** | ||
* Bind Hammer touch interaction to an item. | ||
* Bind touch interaction to an item. | ||
* | ||
@@ -64,38 +60,31 @@ * @class | ||
function ItemDrag(item) { | ||
if (!Hammer) { | ||
throw new Error('[' + namespace + '] required dependency Hammer is not defined.'); | ||
} | ||
// If we don't have a valid transform leak test result yet, let's run the | ||
// test on first ItemDrag init. The test needs body element to be ready and | ||
// here we can be sure that it is ready. | ||
if (hasTransformLeak === null) { | ||
hasTransformLeak = checkTransformLeak(); | ||
} | ||
var drag = this; | ||
var element = item._element; | ||
var grid = item.getGrid(); | ||
var settings = grid._settings; | ||
var hammer; | ||
// Start predicate private data. | ||
var startPredicate = | ||
typeof settings.dragStartPredicate === 'function' | ||
? settings.dragStartPredicate | ||
: ItemDrag.defaultStartPredicate; | ||
var startPredicateState = startPredicateInactive; | ||
var startPredicateResult; | ||
// Protected data. | ||
this._item = item; | ||
this._gridId = grid._id; | ||
this._hammer = hammer = new Hammer.Manager(element); | ||
this._isDestroyed = false; | ||
this._isMigrating = false; | ||
// Start predicate data. | ||
this._startPredicate = isFunction(settings.dragStartPredicate) | ||
? settings.dragStartPredicate | ||
: ItemDrag.defaultStartPredicate; | ||
this._startPredicateState = startPredicateInactive; | ||
this._startPredicateResult = undefined; | ||
// Data for drag sort predicate heuristics. | ||
this._hBlockedIndex = null; | ||
this._hX1 = 0; | ||
this._hX2 = 0; | ||
this._hY1 = 0; | ||
this._hY2 = 0; | ||
// Setup item's initial drag data. | ||
this._reset(); | ||
// Bind some methods that needs binding. | ||
// Bind the methods that needs binding. | ||
this._preStartCheck = this._preStartCheck.bind(this); | ||
this._preEndCheck = this._preEndCheck.bind(this); | ||
this._onScroll = this._onScroll.bind(this); | ||
@@ -108,81 +97,12 @@ this._prepareMove = this._prepareMove.bind(this); | ||
// Create a private drag start resolver that can be used to resolve the drag | ||
// start predicate asynchronously. | ||
this._forceResolveStartPredicate = function(event) { | ||
if (!this._isDestroyed && startPredicateState === startPredicatePending) { | ||
startPredicateState = startPredicateResolved; | ||
this._onStart(event); | ||
} | ||
}; | ||
// Create debounce overlap checker function. | ||
this._checkOverlapDebounce = debounce(this._checkOverlap, settings.dragSortInterval); | ||
var sortInterval = settings.dragSortHeuristics.sortInterval; | ||
this._checkOverlapDebounce = debounce(this._checkOverlap, sortInterval); | ||
// Add drag recognizer to hammer. | ||
hammer.add( | ||
new Hammer.Pan({ | ||
event: 'drag', | ||
pointers: 1, | ||
threshold: 0, | ||
direction: Hammer.DIRECTION_ALL | ||
}) | ||
); | ||
// Add drag init recognizer to hammer. | ||
hammer.add( | ||
new Hammer.Press({ | ||
event: 'draginit', | ||
pointers: 1, | ||
threshold: 1000, | ||
time: 0 | ||
}) | ||
); | ||
// Configure the hammer instance. | ||
if (isPlainObject(settings.dragHammerSettings)) { | ||
hammer.set(settings.dragHammerSettings); | ||
} | ||
// Bind drag events. | ||
hammer | ||
.on('draginit dragstart dragmove', function(e) { | ||
// Let's activate drag start predicate state. | ||
if (startPredicateState === startPredicateInactive) { | ||
startPredicateState = startPredicatePending; | ||
} | ||
// If predicate is pending try to resolve it. | ||
if (startPredicateState === startPredicatePending) { | ||
startPredicateResult = startPredicate(drag._item, e); | ||
if (startPredicateResult === true) { | ||
startPredicateState = startPredicateResolved; | ||
drag._onStart(e); | ||
} else if (startPredicateResult === false) { | ||
startPredicateState = startPredicateRejected; | ||
} | ||
} | ||
// Otherwise if predicate is resolved and drag is active, move the item. | ||
else if (startPredicateState === startPredicateResolved && drag._isActive) { | ||
drag._onMove(e); | ||
} | ||
}) | ||
.on('dragend dragcancel draginitup', function(e) { | ||
// Check if the start predicate was resolved during drag. | ||
var isResolved = startPredicateState === startPredicateResolved; | ||
// Do final predicate check to allow user to unbind stuff for the current | ||
// drag procedure within the predicate callback. The return value of this | ||
// check will have no effect to the state of the predicate. | ||
startPredicate(drag._item, e); | ||
// Reset start predicate state. | ||
startPredicateState = startPredicateInactive; | ||
// If predicate is resolved and dragging is active, call the end handler. | ||
if (isResolved && drag._isActive) drag._onEnd(e); | ||
}); | ||
// Prevent native link/image dragging for the item and it's ancestors. | ||
element.addEventListener('dragstart', preventDefault, false); | ||
// Init dragger. | ||
this._dragger = new Dragger(element, settings.dragCssProps); | ||
this._dragger.on('start', this._preStartCheck); | ||
this._dragger.on('move', this._preStartCheck); | ||
this._dragger.on('cancel', this._preEndCheck); | ||
this._dragger.on('end', this._preEndCheck); | ||
} | ||
@@ -205,3 +125,3 @@ | ||
* @param {Item} item | ||
* @param {Object} event | ||
* @param {DraggerEvent} event | ||
* @param {Object} [options] | ||
@@ -329,3 +249,3 @@ * - An optional options object which can be used to pass the predicate | ||
var sortThreshold = options && typeof options.threshold === 'number' ? options.threshold : 50; | ||
var sortAction = options && options.action === 'swap' ? 'swap' : 'move'; | ||
var sortAction = options && options.action === actionSwap ? actionSwap : actionMove; | ||
@@ -475,4 +395,3 @@ // Populate item rect data. | ||
this.stop(); | ||
this._hammer.destroy(); | ||
this._item._element.removeEventListener('dragstart', preventDefault, false); | ||
this._dragger.destroy(); | ||
this._isDestroyed = true; | ||
@@ -514,5 +433,5 @@ return this; | ||
// Hammer event data. | ||
this._lastEvent = null; | ||
this._lastScrollEvent = null; | ||
// Drag/scroll event data. | ||
this._dragEvent = null; | ||
this._scrollEvent = null; | ||
@@ -553,3 +472,3 @@ // All the elements which need to be listened for scroll events during | ||
var scrollers = this._scrollers; | ||
var containerScrollers; | ||
var gridScrollers; | ||
var i; | ||
@@ -559,3 +478,3 @@ | ||
scrollers.length = 0; | ||
getScrollParents(this._item._element, scrollers); | ||
getScrollableAncestors(this._item._element, false, scrollers); | ||
@@ -566,8 +485,7 @@ // If drag container is defined and it's not the same element as grid | ||
if (dragContainer !== gridContainer) { | ||
containerScrollers = []; | ||
getScrollParents(gridContainer, containerScrollers); | ||
containerScrollers.push(gridContainer); | ||
for (i = 0; i < containerScrollers.length; i++) { | ||
if (scrollers.indexOf(containerScrollers[i]) < 0) { | ||
scrollers.push(containerScrollers[i]); | ||
gridScrollers = []; | ||
getScrollableAncestors(gridContainer, true, gridScrollers); | ||
for (i = 0; i < gridScrollers.length; i++) { | ||
if (scrollers.indexOf(gridScrollers[i]) < 0) { | ||
scrollers.push(gridScrollers[i]); | ||
} | ||
@@ -623,3 +541,3 @@ } | ||
* @memberof ItemDrag.prototype | ||
* @param {Object} event | ||
* @param {DraggerEvent} event | ||
* @returns {?HTMLElement} | ||
@@ -636,3 +554,3 @@ */ | ||
// If there is a specific predicate handle defined, let's try to get it. | ||
handleElement = (event.changedPointers[0] || 0).target; | ||
handleElement = event.target; | ||
while (handleElement && !elementMatches(handleElement, predicate.handle)) { | ||
@@ -650,3 +568,3 @@ handleElement = handleElement !== element ? handleElement.parentElement : null; | ||
* @memberof ItemDrag.prototype | ||
* @param {Object} event | ||
* @param {DraggerEvent} event | ||
* @returns {Boolean} | ||
@@ -656,10 +574,2 @@ */ | ||
var predicate = this._startPredicateData; | ||
var pointer = event.changedPointers[0]; | ||
var pageX = (pointer && pointer.pageX) || 0; | ||
var pageY = (pointer && pointer.pageY) || 0; | ||
var handleRect; | ||
var handleLeft; | ||
var handleTop; | ||
var handleWidth; | ||
var handleHeight; | ||
@@ -671,7 +581,7 @@ // If the moved distance is smaller than the threshold distance or there is | ||
// Get handle rect data. | ||
handleRect = predicate.handleElement.getBoundingClientRect(); | ||
handleLeft = handleRect.left + (window.pageXOffset || 0); | ||
handleTop = handleRect.top + (window.pageYOffset || 0); | ||
handleWidth = handleRect.width; | ||
handleHeight = handleRect.height; | ||
var handleRect = predicate.handleElement.getBoundingClientRect(); | ||
var handleLeft = handleRect.left + (window.pageXOffset || 0); | ||
var handleTop = handleRect.top + (window.pageYOffset || 0); | ||
var handleWidth = handleRect.width; | ||
var handleHeight = handleRect.height; | ||
@@ -685,6 +595,6 @@ // Reset predicate data. | ||
handleHeight && | ||
pageX >= handleLeft && | ||
pageX < handleLeft + handleWidth && | ||
pageY >= handleTop && | ||
pageY < handleTop + handleHeight | ||
event.pageX >= handleLeft && | ||
event.pageX < handleLeft + handleWidth && | ||
event.pageY >= handleTop && | ||
event.pageY < handleTop + handleHeight | ||
); | ||
@@ -694,2 +604,16 @@ }; | ||
/** | ||
* Forcefully resolve drag start predicate. | ||
* | ||
* @private | ||
* @memberof ItemDrag.prototype | ||
* @param {DraggerEvent} event | ||
*/ | ||
ItemDrag.prototype._forceResolveStartPredicate = function(event) { | ||
if (!this._isDestroyed && this._startPredicateState === startPredicatePending) { | ||
this._startPredicateState = startPredicateResolved; | ||
this._onStart(event); | ||
} | ||
}; | ||
/** | ||
* Finalize start predicate. | ||
@@ -699,3 +623,3 @@ * | ||
* @memberof ItemDrag.prototype | ||
* @param {Object} event | ||
* @param {DraggerEvent} event | ||
*/ | ||
@@ -705,2 +629,5 @@ ItemDrag.prototype._finishStartPredicate = function(event) { | ||
// Check if this is a click (very subjective heuristics). | ||
var isClick = Math.abs(event.deltaX) < 2 && Math.abs(event.deltaY) < 2 && event.deltaTime < 200; | ||
// Reset predicate. | ||
@@ -711,6 +638,74 @@ this._resetStartPredicate(); | ||
// href url (if it is an anchor element). | ||
if (isClick(event)) openAnchorHref(element); | ||
if (isClick) openAnchorHref(element); | ||
}; | ||
/** | ||
* Reset drag sort heuristics. | ||
* | ||
* @private | ||
* @memberof ItemDrag.prototype | ||
* @param {DraggerEvent} event | ||
*/ | ||
ItemDrag.prototype._resetHeuristics = function(event) { | ||
this._hBlockedIndex = null; | ||
this._hX1 = this._hX2 = event.clientX; | ||
this._hY1 = this._hY2 = event.clientY; | ||
}; | ||
/** | ||
* Run heuristics and return true if overlap check can be performed, and false | ||
* if it can not. | ||
* | ||
* @private | ||
* @memberof ItemDrag.prototype | ||
* @param {DraggerEvent} event | ||
* @returns {Boolean} | ||
*/ | ||
ItemDrag.prototype._checkHeuristics = function(event) { | ||
var settings = this._getGrid()._settings.dragSortHeuristics; | ||
var minDist = settings.minDragDistance; | ||
// Skip heuristics if not needed. | ||
if (minDist <= 0) { | ||
this._hBlockedIndex = null; | ||
return true; | ||
} | ||
var x = event.clientX; | ||
var y = event.clientY; | ||
var diffX = x - this._hX2; | ||
var diffY = y - this._hY2; | ||
// If we can't do proper bounce back check make sure that the blocked index | ||
// is not set. | ||
var canCheckBounceBack = minDist > 3 && settings.minBounceBackAngle > 0; | ||
if (!canCheckBounceBack) { | ||
this._hBlockedIndex = null; | ||
} | ||
if (Math.abs(diffX) > minDist || Math.abs(diffY) > minDist) { | ||
// Reset blocked index if angle changed enough. This check requires a | ||
// minimum value of 3 for minDragDistance to function properly. | ||
if (canCheckBounceBack) { | ||
var angle = Math.atan2(diffX, diffY); | ||
var prevAngle = Math.atan2(this._hX2 - this._hX1, this._hY2 - this._hY1); | ||
var deltaAngle = Math.atan2(Math.sin(angle - prevAngle), Math.cos(angle - prevAngle)); | ||
if (Math.abs(deltaAngle) > settings.minBounceBackAngle) { | ||
this._hBlockedIndex = null; | ||
} | ||
} | ||
// Update points. | ||
this._hX1 = this._hX2; | ||
this._hY1 = this._hY2; | ||
this._hX2 = x; | ||
this._hY2 = y; | ||
return true; | ||
} | ||
return false; | ||
}; | ||
/** | ||
* Reset for default drag start predicate function. | ||
@@ -752,4 +747,4 @@ * | ||
// Get overlap check result. | ||
if (typeof settings.dragSortPredicate === 'function') { | ||
result = settings.dragSortPredicate(item, this._lastEvent); | ||
if (isFunction(settings.dragSortPredicate)) { | ||
result = settings.dragSortPredicate(item, this._dragEvent); | ||
} else { | ||
@@ -767,4 +762,9 @@ result = ItemDrag.defaultSortPredicate(item, settings.dragSortPredicate); | ||
targetIndex = normalizeArrayIndex(targetGrid._items, result.index, isMigration); | ||
sortAction = result.action === 'swap' ? 'swap' : 'move'; | ||
sortAction = result.action === actionSwap ? actionSwap : actionMove; | ||
// Prevent position bounce. | ||
if (!isMigration && targetIndex === this._hBlockedIndex) { | ||
return; | ||
} | ||
// If the item was moved within it's current grid. | ||
@@ -774,4 +774,6 @@ if (!isMigration) { | ||
if (currentIndex !== targetIndex) { | ||
this._hBlockedIndex = currentIndex; | ||
// Do the sort. | ||
(sortAction === 'swap' ? arraySwap : arrayMove)( | ||
(sortAction === actionSwap ? arraySwap : arrayMove)( | ||
currentGrid._items, | ||
@@ -799,2 +801,4 @@ currentIndex, | ||
else { | ||
this._hBlockedIndex = null; | ||
// Emit beforeSend event. | ||
@@ -940,2 +944,55 @@ if (currentGrid._hasListeners(eventBeforeSend)) { | ||
/** | ||
* Drag pre-start handler. | ||
* | ||
* @private | ||
* @memberof ItemDrag.prototype | ||
* @param {DraggerEvent} event | ||
*/ | ||
ItemDrag.prototype._preStartCheck = function(event) { | ||
// Let's activate drag start predicate state. | ||
if (this._startPredicateState === startPredicateInactive) { | ||
this._startPredicateState = startPredicatePending; | ||
} | ||
// If predicate is pending try to resolve it. | ||
if (this._startPredicateState === startPredicatePending) { | ||
this._startPredicateResult = this._startPredicate(this._item, event); | ||
if (this._startPredicateResult === true) { | ||
this._startPredicateState = startPredicateResolved; | ||
this._onStart(event); | ||
} else if (this._startPredicateResult === false) { | ||
this._startPredicateState = startPredicateRejected; | ||
} | ||
} | ||
// Otherwise if predicate is resolved and drag is active, move the item. | ||
else if (this._startPredicateState === startPredicateResolved && this._isActive) { | ||
this._onMove(event); | ||
} | ||
}; | ||
/** | ||
* Drag pre-end handler. | ||
* | ||
* @private | ||
* @memberof ItemDrag.prototype | ||
* @param {DraggerEvent} event | ||
*/ | ||
ItemDrag.prototype._preEndCheck = function(event) { | ||
// Check if the start predicate was resolved during drag. | ||
var isResolved = this._startPredicateState === startPredicateResolved; | ||
// Do final predicate check to allow user to unbind stuff for the current | ||
// drag procedure within the predicate callback. The return value of this | ||
// check will have no effect to the state of the predicate. | ||
this._startPredicate(this._item, event); | ||
// Reset start predicate state. | ||
this._startPredicateState = startPredicateInactive; | ||
// If predicate is resolved and dragging is active, call the end handler. | ||
if (isResolved && this._isActive) this._onEnd(event); | ||
}; | ||
/** | ||
* Drag start handler. | ||
@@ -945,3 +1002,3 @@ * | ||
* @memberof ItemDrag.prototype | ||
* @param {Object} event | ||
* @param {DraggerEvent} event | ||
*/ | ||
@@ -969,2 +1026,5 @@ ItemDrag.prototype._onStart = function(event) { | ||
// Reset heuristics data. | ||
this._resetHeuristics(event); | ||
// If grid container is not the drag container, we need to calculate the | ||
@@ -994,3 +1054,3 @@ // offset difference between grid container and drag container's containing | ||
this._isActive = true; | ||
this._lastEvent = event; | ||
this._dragEvent = event; | ||
this._container = dragContainer; | ||
@@ -1003,2 +1063,7 @@ this._containingBlock = containingBlock; | ||
// Create placeholder (if necessary). | ||
if (settings.dragPlaceholder.enabled) { | ||
item._dragPlaceholder.create(); | ||
} | ||
// Emit dragInit event. | ||
@@ -1045,3 +1110,3 @@ grid._emit(eventDragInit, item, event); | ||
* @memberof ItemDrag.prototype | ||
* @param {Object} event | ||
* @param {DraggerEvent} event | ||
*/ | ||
@@ -1059,10 +1124,6 @@ ItemDrag.prototype._onMove = function(event) { | ||
var axis = settings.dragAxis; | ||
var xDiff = event.deltaX - this._lastEvent.deltaX; | ||
var yDiff = event.deltaY - this._lastEvent.deltaY; | ||
// Update last event. | ||
this._lastEvent = event; | ||
// Update horizontal position data. | ||
if (axis !== 'y') { | ||
var xDiff = event.clientX - this._dragEvent.clientX; | ||
this._left += xDiff; | ||
@@ -1075,2 +1136,3 @@ this._gridX += xDiff; | ||
if (axis !== 'x') { | ||
var yDiff = event.clientY - this._dragEvent.clientY; | ||
this._top += yDiff; | ||
@@ -1081,2 +1143,5 @@ this._gridY += yDiff; | ||
// Update event data. | ||
this._dragEvent = event; | ||
// Do move prepare/apply handling in the next tick. | ||
@@ -1097,3 +1162,7 @@ addMoveTick(item._id, this._prepareMove, this._applyMove); | ||
// If drag sort is enabled -> check overlap. | ||
if (this._getGrid()._settings.dragSort) this._checkOverlapDebounce(); | ||
if (this._getGrid()._settings.dragSort) { | ||
if (this._checkHeuristics(this._dragEvent)) { | ||
this._checkOverlapDebounce(); | ||
} | ||
} | ||
}; | ||
@@ -1117,3 +1186,3 @@ | ||
// Emit dragMove event. | ||
this._getGrid()._emit(eventDragMove, item, this._lastEvent); | ||
this._getGrid()._emit(eventDragMove, item, this._dragEvent); | ||
}; | ||
@@ -1126,3 +1195,3 @@ | ||
* @memberof ItemDrag.prototype | ||
* @param {Object} event | ||
* @param {Event} event | ||
*/ | ||
@@ -1139,3 +1208,3 @@ ItemDrag.prototype._onScroll = function(event) { | ||
// Update last scroll event. | ||
this._lastScrollEvent = event; | ||
this._scrollEvent = event; | ||
@@ -1209,3 +1278,3 @@ // Do scroll prepare/apply handling in the next tick. | ||
// Emit dragScroll event. | ||
this._getGrid()._emit(eventDragScroll, item, this._lastScrollEvent); | ||
this._getGrid()._emit(eventDragScroll, item, this._scrollEvent); | ||
}; | ||
@@ -1218,3 +1287,3 @@ | ||
* @memberof ItemDrag.prototype | ||
* @param {Object} event | ||
* @param {DraggerEvent} event | ||
*/ | ||
@@ -1267,11 +1336,2 @@ ItemDrag.prototype._onEnd = function(event) { | ||
/** | ||
* Prevent default. | ||
* | ||
* @param {Object} e | ||
*/ | ||
function preventDefault(e) { | ||
if (e.preventDefault) e.preventDefault(); | ||
} | ||
/** | ||
* Calculate how many percent the intersection area of two rectangles is from | ||
@@ -1306,97 +1366,2 @@ * the maximum potential intersection area between the rectangles. | ||
/** | ||
* Get element's scroll parents. | ||
* | ||
* @param {HTMLElement} element | ||
* @param {Array} [data] | ||
* @returns {HTMLElement[]} | ||
*/ | ||
function getScrollParents(element, data) { | ||
var ret = data || []; | ||
var parent = element.parentNode; | ||
// | ||
// If transformed elements leak fixed elements. | ||
// | ||
if (hasTransformLeak) { | ||
// If the element is fixed it can not have any scroll parents. | ||
if (getStyle(element, 'position') === 'fixed') return ret; | ||
// Find scroll parents. | ||
while (parent && parent !== document && parent !== document.documentElement) { | ||
if (isScrollable(parent)) ret.push(parent); | ||
parent = getStyle(parent, 'position') === 'fixed' ? null : parent.parentNode; | ||
} | ||
// If parent is not fixed element, add window object as the last scroll | ||
// parent. | ||
parent !== null && ret.push(window); | ||
return ret; | ||
} | ||
// | ||
// If fixed elements behave as defined in the W3C specification. | ||
// | ||
// Find scroll parents. | ||
while (parent && parent !== document) { | ||
// If the currently looped element is fixed ignore all parents that are | ||
// not transformed. | ||
if (getStyle(element, 'position') === 'fixed' && !isTransformed(parent)) { | ||
parent = parent.parentNode; | ||
continue; | ||
} | ||
// Add the parent element to return items if it is scrollable. | ||
if (isScrollable(parent)) ret.push(parent); | ||
// Update element and parent references. | ||
element = parent; | ||
parent = parent.parentNode; | ||
} | ||
// If the last item is the root element, replace it with window. The root | ||
// element scroll is propagated to the window. | ||
if (ret[ret.length - 1] === document.documentElement) { | ||
ret[ret.length - 1] = window; | ||
} | ||
// Otherwise add window as the last scroll parent. | ||
else { | ||
ret.push(window); | ||
} | ||
return ret; | ||
} | ||
/** | ||
* Check if an element is scrollable. | ||
* | ||
* @param {HTMLElement} element | ||
* @returns {Boolean} | ||
*/ | ||
function isScrollable(element) { | ||
var overflow = getStyle(element, 'overflow'); | ||
if (overflow === 'auto' || overflow === 'scroll') return true; | ||
overflow = getStyle(element, 'overflow-x'); | ||
if (overflow === 'auto' || overflow === 'scroll') return true; | ||
overflow = getStyle(element, 'overflow-y'); | ||
if (overflow === 'auto' || overflow === 'scroll') return true; | ||
return false; | ||
} | ||
/** | ||
* Check if drag gesture can be interpreted as a click, based on final drag | ||
* event data. | ||
* | ||
* @param {Object} element | ||
* @returns {Boolean} | ||
*/ | ||
function isClick(event) { | ||
return Math.abs(event.deltaX) < 2 && Math.abs(event.deltaY) < 2 && event.deltaTime < 200; | ||
} | ||
/** | ||
* Check if an element is an anchor element and open the href url if possible. | ||
@@ -1423,39 +1388,2 @@ * | ||
/** | ||
* Detects if transformed elements leak fixed elements. According W3C | ||
* transform rendering spec a transformed element should contain even fixed | ||
* elements. Meaning that fixed elements are positioned relative to the | ||
* closest transformed ancestor element instead of window. However, not every | ||
* browser follows the spec (IE and older Firefox). So we need to test it. | ||
* https://www.w3.org/TR/css3-2d-transforms/#transform-rendering | ||
* | ||
* Borrowed from Mezr (v0.6.1): | ||
* https://github.com/niklasramo/mezr/blob/0.6.1/mezr.js#L607 | ||
*/ | ||
function checkTransformLeak() { | ||
// No transforms -> definitely leaks. | ||
if (!isTransformSupported) return true; | ||
// No body available -> can't check it. | ||
if (!document.body) return null; | ||
// Do the test. | ||
var elems = [0, 1].map(function(elem, isInner) { | ||
elem = document.createElement('div'); | ||
elem.style.position = isInner ? 'fixed' : 'absolute'; | ||
elem.style.display = 'block'; | ||
elem.style.visibility = 'hidden'; | ||
elem.style.left = isInner ? '0px' : '1px'; | ||
elem.style[transformProp] = 'none'; | ||
return elem; | ||
}); | ||
var outer = document.body.appendChild(elems[0]); | ||
var inner = outer.appendChild(elems[1]); | ||
var left = inner.getBoundingClientRect().left; | ||
outer.style[transformProp] = 'scale(1)'; | ||
var ret = left === inner.getBoundingClientRect().left; | ||
document.body.removeChild(outer); | ||
return ret; | ||
} | ||
export default ItemDrag; |
@@ -7,11 +7,12 @@ /** | ||
import { addLayoutTick, cancelLayoutTick } from '../ticker.js'; | ||
import { addLayoutTick, cancelLayoutTick } from '../ticker'; | ||
import Queue from '../Queue/Queue.js'; | ||
import Queue from '../Queue/Queue'; | ||
import addClass from '../utils/addClass.js'; | ||
import getTranslate from '../utils/getTranslate.js'; | ||
import getTranslateString from '../utils/getTranslateString.js'; | ||
import removeClass from '../utils/removeClass.js'; | ||
import setStyles from '../utils/setStyles.js'; | ||
import addClass from '../utils/addClass'; | ||
import getTranslate from '../utils/getTranslate'; | ||
import getTranslateString from '../utils/getTranslateString'; | ||
import isFunction from '../utils/isFunction'; | ||
import removeClass from '../utils/removeClass'; | ||
import setStyles from '../utils/setStyles'; | ||
@@ -84,3 +85,3 @@ /** | ||
// Push the callback to the callback queue. | ||
if (typeof onFinish === 'function') this._queue.add(onFinish); | ||
if (isFunction(onFinish)) this._queue.add(onFinish); | ||
@@ -91,3 +92,2 @@ // If no animations are needed, easy peasy! | ||
this._updateTargetStyles(); | ||
isPositioning && cancelLayoutTick(item._id); | ||
isAnimating = item._animate.isAnimating(); | ||
@@ -182,4 +182,4 @@ this.stop(false, this._targetStyles); | ||
: migrate._isActive | ||
? migrate._containerDiffX | ||
: 0; | ||
? migrate._containerDiffX | ||
: 0; | ||
@@ -189,4 +189,4 @@ this._offsetTop = release._isActive | ||
: migrate._isActive | ||
? migrate._containerDiffY | ||
: 0; | ||
? migrate._containerDiffY | ||
: 0; | ||
}; | ||
@@ -202,8 +202,5 @@ | ||
if (this._isDestroyed) return; | ||
var item = this._item; | ||
this._targetStyles.transform = getTranslateString( | ||
item._left + this._offsetLeft, | ||
item._top + this._offsetTop | ||
this._item._left + this._offsetLeft, | ||
this._item._top + this._offsetTop | ||
); | ||
@@ -246,4 +243,3 @@ }; | ||
ItemLayout.prototype._setupAnimation = function() { | ||
var element = this._item._element; | ||
var translate = getTranslate(element); | ||
var translate = getTranslate(this._item._element); | ||
this._currentLeft = translate.x; | ||
@@ -261,5 +257,3 @@ this._currentTop = translate.y; | ||
var item = this._item; | ||
var element = item._element; | ||
var grid = item.getGrid(); | ||
var settings = grid._settings; | ||
var settings = item.getGrid()._settings; | ||
@@ -282,3 +276,5 @@ // Let's update the offset data and target styles. | ||
// Set item's positioning class if needed. | ||
!this._isInterrupted && addClass(element, settings.itemPositioningClass); | ||
if (!this._isInterrupted) { | ||
addClass(item._element, settings.itemPositioningClass); | ||
} | ||
@@ -285,0 +281,0 @@ // Get current styles for animation. |
@@ -7,15 +7,15 @@ /** | ||
import { eventBeforeSend, eventBeforeReceive, eventSend, eventReceive } from '../shared.js'; | ||
import { eventBeforeSend, eventBeforeReceive, eventSend, eventReceive } from '../shared'; | ||
import ItemDrag from './ItemDrag.js'; | ||
import ItemDrag from './ItemDrag'; | ||
import addClass from '../utils/addClass.js'; | ||
import getOffsetDiff from '../utils/getOffsetDiff.js'; | ||
import getTranslate from '../utils/getTranslate.js'; | ||
import getTranslateString from '../utils/getTranslateString.js'; | ||
import arrayInsert from '../utils/arrayInsert.js'; | ||
import normalizeArrayIndex from '../utils/normalizeArrayIndex.js'; | ||
import removeClass from '../utils/removeClass.js'; | ||
import setStyles from '../utils/setStyles.js'; | ||
import { transformProp } from '../utils/supportedTransform.js'; | ||
import addClass from '../utils/addClass'; | ||
import getOffsetDiff from '../utils/getOffsetDiff'; | ||
import getTranslate from '../utils/getTranslate'; | ||
import getTranslateString from '../utils/getTranslateString'; | ||
import arrayInsert from '../utils/arrayInsert'; | ||
import normalizeArrayIndex from '../utils/normalizeArrayIndex'; | ||
import removeClass from '../utils/removeClass'; | ||
import setStyles from '../utils/setStyles'; | ||
import { transformProp } from '../utils/supportedTransform'; | ||
@@ -67,3 +67,3 @@ var tempStyles = {}; | ||
var currentIndex = grid._items.indexOf(item); | ||
var targetContainer = container || document.body; | ||
var targetContainer = container || window.document.body; | ||
var targetIndex; | ||
@@ -70,0 +70,0 @@ var targetItem; |
@@ -7,9 +7,9 @@ /** | ||
import { eventDragReleaseStart, eventDragReleaseEnd } from '../shared.js'; | ||
import { eventDragReleaseStart, eventDragReleaseEnd } from '../shared'; | ||
import addClass from '../utils/addClass.js'; | ||
import getTranslate from '../utils/getTranslate.js'; | ||
import getTranslateString from '../utils/getTranslateString.js'; | ||
import removeClass from '../utils/removeClass.js'; | ||
import setStyles from '../utils/setStyles.js'; | ||
import addClass from '../utils/addClass'; | ||
import getTranslate from '../utils/getTranslate'; | ||
import getTranslateString from '../utils/getTranslateString'; | ||
import removeClass from '../utils/removeClass'; | ||
import setStyles from '../utils/setStyles'; | ||
@@ -16,0 +16,0 @@ var tempStyles = {}; |
@@ -7,11 +7,12 @@ /** | ||
import { addVisibilityTick, cancelVisibilityTick } from '../ticker.js'; | ||
import { addVisibilityTick, cancelVisibilityTick } from '../ticker'; | ||
import Queue from '../Queue/Queue.js'; | ||
import Queue from '../Queue/Queue'; | ||
import addClass from '../utils/addClass.js'; | ||
import getCurrentStyles from '../utils/getCurrentStyles.js'; | ||
import getTranslateString from '../utils/getTranslateString.js'; | ||
import removeClass from '../utils/removeClass.js'; | ||
import setStyles from '../utils/setStyles.js'; | ||
import addClass from '../utils/addClass'; | ||
import getCurrentStyles from '../utils/getCurrentStyles'; | ||
import getTranslateString from '../utils/getTranslateString'; | ||
import isFunction from '../utils/isFunction'; | ||
import removeClass from '../utils/removeClass'; | ||
import setStyles from '../utils/setStyles'; | ||
@@ -74,3 +75,3 @@ /** | ||
var queue = this._queue; | ||
var callback = typeof onFinish === 'function' ? onFinish : null; | ||
var callback = isFunction(onFinish) ? onFinish : null; | ||
var grid = item.getGrid(); | ||
@@ -130,3 +131,3 @@ var settings = grid._settings; | ||
var queue = this._queue; | ||
var callback = typeof onFinish === 'function' ? onFinish : null; | ||
var callback = isFunction(onFinish) ? onFinish : null; | ||
var grid = item.getGrid(); | ||
@@ -133,0 +134,0 @@ var settings = grid._settings; |
@@ -117,3 +117,3 @@ /** | ||
Packer.prototype._addSlot = (function() { | ||
var leeway = 0.001; | ||
var eps = 0.001; | ||
var itemSlot = {}; | ||
@@ -151,3 +151,3 @@ return function(item, isHorizontal, fillGaps, rounding, trackSize) { | ||
rect = this._getRect(rectId); | ||
if (itemSlot.width <= rect.width + leeway && itemSlot.height <= rect.height + leeway) { | ||
if (itemSlot.width <= rect.width + eps && itemSlot.height <= rect.height + eps) { | ||
itemSlot.left = rect.left; | ||
@@ -166,3 +166,3 @@ itemSlot.top = rect.top; | ||
// If gaps don't needs filling do not add any current slots to the new | ||
// If gaps don't need filling do not add any current slots to the new | ||
// slots array. | ||
@@ -169,0 +169,0 @@ if (!fillGaps) { |
@@ -10,2 +10,5 @@ /** | ||
export var actionSwap = 'swap'; | ||
export var actionMove = 'move'; | ||
export var eventSynchronize = 'synchronize'; | ||
@@ -12,0 +15,0 @@ export var eventLayoutStart = 'layoutStart'; |
@@ -7,3 +7,3 @@ /** | ||
import Ticker from './Ticker/Ticker.js'; | ||
import Ticker from './Ticker/Ticker'; | ||
@@ -16,2 +16,3 @@ var ticker = new Ticker(); | ||
var scrollTick = 'scroll'; | ||
var placeholderTick = 'placeholder'; | ||
@@ -51,1 +52,9 @@ export default ticker; | ||
} | ||
export function addPlaceholderTick(itemId, readCallback, writeCallback) { | ||
return ticker.add(itemId + placeholderTick, readCallback, writeCallback); | ||
} | ||
export function cancelPlaceholderTick(itemId) { | ||
return ticker.cancel(itemId + placeholderTick); | ||
} |
@@ -8,14 +8,4 @@ /** | ||
var raf = ( | ||
window.requestAnimationFrame || | ||
window.webkitRequestAnimationFrame || | ||
window.mozRequestAnimationFrame || | ||
window.msRequestAnimationFrame || | ||
rafFallback | ||
).bind(window); | ||
import raf from '../utils/raf'; | ||
function rafFallback(cb) { | ||
return window.setTimeout(cb, 16); | ||
} | ||
/** | ||
@@ -29,3 +19,3 @@ * A ticker system for handling DOM reads and writes in an efficient way. | ||
function Ticker() { | ||
this._nextTick = null; | ||
this._nextStep = null; | ||
@@ -40,6 +30,6 @@ this._queue = []; | ||
this._flush = this._flush.bind(this); | ||
this._step = this._step.bind(this); | ||
} | ||
Ticker.prototype.add = function(id, readCallback, writeCallback, isImportant) { | ||
Ticker.prototype.add = function(id, readOperation, writeOperation, isPrioritized) { | ||
// First, let's check if an item has been added to the queues with the same id | ||
@@ -50,12 +40,9 @@ // and if so -> remove it. | ||
// Add all important callbacks to the beginning of the queue and other | ||
// callbacks to the end of the queue. | ||
isImportant ? this._queue.unshift(id) : this._queue.push(id); | ||
// Add entry. | ||
isPrioritized ? this._queue.unshift(id) : this._queue.push(id); | ||
this._reads[id] = readOperation; | ||
this._writes[id] = writeOperation; | ||
// Store callbacks. | ||
this._reads[id] = readCallback; | ||
this._writes[id] = writeCallback; | ||
// Finally, let's kick-start the next tick if it is not running yet. | ||
if (!this._nextTick) this._nextTick = raf(this._flush); | ||
if (!this._nextStep) this._nextStep = raf(this._step); | ||
}; | ||
@@ -67,8 +54,8 @@ | ||
this._queue[currentIndex] = undefined; | ||
this._reads[id] = undefined; | ||
this._writes[id] = undefined; | ||
delete this._reads[id]; | ||
delete this._writes[id]; | ||
} | ||
}; | ||
Ticker.prototype._flush = function() { | ||
Ticker.prototype._step = function() { | ||
var queue = this._queue; | ||
@@ -85,3 +72,3 @@ var reads = this._reads; | ||
// Reset ticker. | ||
this._nextTick = null; | ||
this._nextStep = null; | ||
@@ -96,6 +83,6 @@ // Setup queues and callback placeholders. | ||
batchReads[id] = reads[id]; | ||
reads[id] = undefined; | ||
delete reads[id]; | ||
batchWrites[id] = writes[id]; | ||
writes[id] = undefined; | ||
delete writes[id]; | ||
} | ||
@@ -111,3 +98,3 @@ | ||
batchReads[id](); | ||
batchReads[id] = undefined; | ||
delete batchReads[id]; | ||
} | ||
@@ -121,3 +108,3 @@ } | ||
batchWrites[id](); | ||
batchWrites[id] = undefined; | ||
delete batchWrites[id]; | ||
} | ||
@@ -130,4 +117,4 @@ } | ||
// Restart the ticker if needed. | ||
if (!this._nextTick && queue.length) { | ||
this._nextTick = raf(this._flush); | ||
if (!this._nextStep && queue.length) { | ||
this._nextStep = raf(this._step); | ||
} | ||
@@ -134,0 +121,0 @@ }; |
@@ -7,3 +7,3 @@ /** | ||
import elementMatches from './elementMatches.js'; | ||
import elementMatches from './elementMatches'; | ||
@@ -16,18 +16,10 @@ /** | ||
*/ | ||
function addClassModern(element, className) { | ||
element.classList.add(className); | ||
} | ||
/** | ||
* Add class to an element (legacy version, for IE9 support). | ||
* | ||
* @param {HTMLElement} element | ||
* @param {String} className | ||
*/ | ||
function addClassLegacy(element, className) { | ||
if (!elementMatches(element, '.' + className)) { | ||
element.className += ' ' + className; | ||
export default function addClass(element, className) { | ||
if (element.classList) { | ||
element.classList.add(className); | ||
} else { | ||
if (!elementMatches(element, '.' + className)) { | ||
element.className += ' ' + className; | ||
} | ||
} | ||
} | ||
export default ('classList' in Element.prototype ? addClassModern : addClassLegacy); |
@@ -8,2 +8,3 @@ /** | ||
var tempArray = []; | ||
var numberType = 'number'; | ||
@@ -20,3 +21,3 @@ /** | ||
export default function arrayInsert(array, items, index) { | ||
var startIndex = typeof index === 'number' ? index : -1; | ||
var startIndex = typeof index === numberType ? index : -1; | ||
if (startIndex < 0) startIndex = array.length - startIndex + 1; | ||
@@ -23,0 +24,0 @@ |
@@ -7,3 +7,3 @@ /** | ||
import normalizeArrayIndex from './normalizeArrayIndex.js'; | ||
import normalizeArrayIndex from './normalizeArrayIndex'; | ||
@@ -10,0 +10,0 @@ /** |
@@ -7,3 +7,3 @@ /** | ||
import normalizeArrayIndex from './normalizeArrayIndex.js'; | ||
import normalizeArrayIndex from './normalizeArrayIndex'; | ||
@@ -10,0 +10,0 @@ /** |
@@ -7,4 +7,8 @@ /** | ||
import ticker from '../ticker'; | ||
var actionCancel = 'cancel'; | ||
var actionFinish = 'finish'; | ||
var debounceTick = 'debounce'; | ||
var debounceId = 0; | ||
@@ -25,2 +29,3 @@ /** | ||
var timeout; | ||
var tickerId = ++debounceId + debounceTick; | ||
@@ -31,2 +36,3 @@ if (wait > 0) { | ||
timeout = window.clearTimeout(timeout); | ||
ticker.cancel(tickerId); | ||
if (action === actionFinish) fn(); | ||
@@ -38,3 +44,3 @@ } | ||
timeout = undefined; | ||
fn(); | ||
ticker.add(tickerId, fn, null, true); | ||
}, wait); | ||
@@ -41,0 +47,0 @@ } |
@@ -7,10 +7,13 @@ /** | ||
var proto = Element.prototype; | ||
var matches = | ||
proto.matches || | ||
proto.matchesSelector || | ||
proto.webkitMatchesSelector || | ||
proto.mozMatchesSelector || | ||
proto.msMatchesSelector || | ||
proto.oMatchesSelector; | ||
var ElProto = window.Element.prototype; | ||
var matchesFn = | ||
ElProto.matches || | ||
ElProto.matchesSelector || | ||
ElProto.webkitMatchesSelector || | ||
ElProto.mozMatchesSelector || | ||
ElProto.msMatchesSelector || | ||
ElProto.oMatchesSelector || | ||
function() { | ||
return false; | ||
}; | ||
@@ -20,7 +23,8 @@ /** | ||
* | ||
* @param {*} val | ||
* @param {Element} el | ||
* @param {String} selector | ||
* @returns {Boolean} | ||
*/ | ||
export default function elementMatches(el, selector) { | ||
return matches.call(el, selector); | ||
return matchesFn.call(el, selector); | ||
} |
@@ -7,3 +7,3 @@ /** | ||
import getStyle from './getStyle.js'; | ||
import getStyle from './getStyle'; | ||
import isTransformed from './isTransformed'; | ||
@@ -28,2 +28,3 @@ | ||
// document. https://github.com/niklasramo/mezr/blob/0.6.1/mezr.js#L339 | ||
var document = window.document; | ||
var ret = (includeSelf ? element : element.parentElement) || document; | ||
@@ -30,0 +31,0 @@ while (ret && ret !== document && getStyle(ret, 'position') === 'static' && !isTransformed(ret)) { |
@@ -7,4 +7,4 @@ /** | ||
import getStyle from './getStyle.js'; | ||
import getStyleName from './getStyleName.js'; | ||
import getStyle from './getStyle'; | ||
import getStyleName from './getStyleName'; | ||
@@ -11,0 +11,0 @@ /** |
@@ -7,4 +7,4 @@ /** | ||
import getContainingBlock from './getContainingBlock.js'; | ||
import getStyleAsFloat from './getStyleAsFloat.js'; | ||
import getContainingBlock from './getContainingBlock'; | ||
import getStyleAsFloat from './getStyleAsFloat'; | ||
@@ -11,0 +11,0 @@ var offsetA = {}; |
@@ -7,3 +7,3 @@ /** | ||
import { transformStyle } from './supportedTransform.js'; | ||
import { transformStyle } from './supportedTransform'; | ||
@@ -23,5 +23,5 @@ var stylesCache = typeof WeakMap === 'function' ? new WeakMap() : null; | ||
styles = window.getComputedStyle(element, null); | ||
stylesCache && stylesCache.set(element, styles); | ||
if (stylesCache) stylesCache.set(element, styles); | ||
} | ||
return styles.getPropertyValue(style === 'transform' ? transformStyle : style); | ||
} |
@@ -7,3 +7,3 @@ /** | ||
import getStyle from './getStyle.js'; | ||
import getStyle from './getStyle'; | ||
@@ -10,0 +10,0 @@ /** |
@@ -7,5 +7,11 @@ /** | ||
import getStyle from './getStyle.js'; | ||
import getStyle from './getStyle'; | ||
var translateData = {}; | ||
var translateValue = {}; | ||
var transformStyle = 'transform'; | ||
var transformNone = 'none'; | ||
var rxMat3d = /^matrix3d/; | ||
var rxMatTx = /([^,]*,){4}/; | ||
var rxMat3dTx = /([^,]*,){12}/; | ||
var rxNextItem = /[^,]*,/; | ||
@@ -21,13 +27,19 @@ /** | ||
export default function getTranslate(element) { | ||
translateData.x = 0; | ||
translateData.y = 0; | ||
translateValue.x = 0; | ||
translateValue.y = 0; | ||
var transform = getStyle(element, 'transform'); | ||
if (!transform) return translateData; | ||
var transform = getStyle(element, transformStyle); | ||
if (!transform || transform === transformNone) { | ||
return translateValue; | ||
} | ||
var matrixData = transform.replace('matrix(', '').split(','); | ||
translateData.x = parseFloat(matrixData[4]) || 0; | ||
translateData.y = parseFloat(matrixData[5]) || 0; | ||
// Transform style can be in either matrix3d(...) or matrix(...). | ||
var isMat3d = rxMat3d.test(transform); | ||
var tX = transform.replace(isMat3d ? rxMat3dTx : rxMatTx, ''); | ||
var tY = tX.replace(rxNextItem, ''); | ||
return translateData; | ||
translateValue.x = parseFloat(tX) || 0; | ||
translateValue.y = parseFloat(tY) || 0; | ||
return translateValue; | ||
} |
@@ -7,3 +7,4 @@ /** | ||
var objectType = '[object Object]'; | ||
var objectType = 'object'; | ||
var objectToStringType = '[object Object]'; | ||
var toString = Object.prototype.toString; | ||
@@ -18,3 +19,3 @@ | ||
export default function isPlainObject(val) { | ||
return typeof val === 'object' && toString.call(val) === objectType; | ||
return typeof val === objectType && toString.call(val) === objectToStringType; | ||
} |
@@ -7,3 +7,3 @@ /** | ||
import getStyle from './getStyle.js'; | ||
import getStyle from './getStyle'; | ||
@@ -10,0 +10,0 @@ /** |
@@ -7,3 +7,3 @@ /** | ||
import elementMatches from './elementMatches.js'; | ||
import elementMatches from './elementMatches'; | ||
@@ -16,18 +16,12 @@ /** | ||
*/ | ||
function removeClassModern(element, className) { | ||
element.classList.remove(className); | ||
} | ||
/** | ||
* Remove class from an element (legacy version, for IE9 support). | ||
* | ||
* @param {HTMLElement} element | ||
* @param {String} className | ||
*/ | ||
function removeClassLegacy(element, className) { | ||
if (elementMatches(element, '.' + className)) { | ||
element.className = (' ' + element.className + ' ').replace(' ' + className + ' ', ' ').trim(); | ||
export default function removeClass(element, className) { | ||
if (element.classList) { | ||
element.classList.remove(className); | ||
} else { | ||
if (elementMatches(element, '.' + className)) { | ||
element.className = (' ' + element.className + ' ') | ||
.replace(' ' + className + ' ', ' ') | ||
.trim(); | ||
} | ||
} | ||
} | ||
export default ('classList' in Element.prototype ? removeClassModern : removeClassLegacy); |
@@ -7,4 +7,6 @@ /** | ||
import { transformProp } from './supportedTransform.js'; | ||
import { transformProp } from './supportedTransform'; | ||
var transformStyle = 'transform'; | ||
/** | ||
@@ -18,4 +20,4 @@ * Set inline styles to an element. | ||
for (var prop in styles) { | ||
element.style[prop === 'transform' ? transformProp : prop] = styles[prop]; | ||
element.style[prop === transformStyle ? transformProp : prop] = styles[prop]; | ||
} | ||
} |
@@ -8,3 +8,2 @@ /** | ||
// Set up the default export values. | ||
export var isTransformSupported = false; | ||
export var transformStyle = 'transform'; | ||
@@ -14,13 +13,15 @@ export var transformProp = 'transform'; | ||
// Find the supported transform prop and style names. | ||
var docElemStyle = window.document.documentElement.style; | ||
var style = 'transform'; | ||
var styleCap = 'Transform'; | ||
var found = false; | ||
['', 'Webkit', 'Moz', 'O', 'ms'].forEach(function(prefix) { | ||
if (isTransformSupported) return; | ||
if (found) return; | ||
var propName = prefix ? prefix + styleCap : style; | ||
if (document.documentElement.style[propName] !== undefined) { | ||
if (docElemStyle[propName] !== undefined) { | ||
prefix = prefix.toLowerCase(); | ||
transformStyle = prefix ? '-' + prefix + '-' + style : style; | ||
transformProp = propName; | ||
isTransformSupported = true; | ||
found = true; | ||
} | ||
}); |
@@ -7,3 +7,3 @@ /** | ||
import isNodeList from './isNodeList.js'; | ||
import isNodeList from './isNodeList'; | ||
@@ -10,0 +10,0 @@ /** |
(function (window) { | ||
var Muuri = window.Muuri; | ||
var idList = utils.idList; | ||
@@ -6,0 +5,0 @@ QUnit.module('Grid events'); |
@@ -9,3 +9,3 @@ (function (window) { | ||
assert.expect(6); | ||
assert.expect(9); | ||
@@ -36,5 +36,10 @@ var done = assert.async(); | ||
assert.strictEqual(draggedItem, item, 'callback: first argument should be the dragged item'); | ||
assert.strictEqual(utils.isHammerEvent(ev), true, 'callback: second argument should be a hammer event object'); | ||
assert.strictEqual(isStartCalled, true, 'callback: should be called after dragStart'); | ||
assert.strictEqual(isMoveCalled, true, 'callback: should be called after dragMove'); | ||
assert.strictEqual(utils.isDraggerEvent(ev), true, 'callback: second argument should be a Dragger event object'); | ||
assert.strictEqual(ev.isFirst, false, 'event.isFirst should be false'); | ||
assert.strictEqual(ev.isFinal, true, 'event.isFinal should be true'); | ||
assert.strictEqual(ev.type, 'end', 'event.type should be "end"'); | ||
++calls; | ||
@@ -41,0 +46,0 @@ }); |
@@ -9,3 +9,3 @@ (function (window) { | ||
assert.expect(6); | ||
assert.expect(9); | ||
@@ -29,5 +29,10 @@ var done = assert.async(); | ||
assert.strictEqual(draggedItem, item, 'callback: first argument should be the dragged item'); | ||
assert.strictEqual(utils.isHammerEvent(ev), true, 'callback: second argument should be a hammer event object'); | ||
assert.strictEqual(utils.matches(draggedItem.getElement(), '.muuri-item-dragging'), false, 'should be called before dragging classname is set'); | ||
assert.strictEqual(draggedItem.getElement().parentNode, container, 'should be called before dragged element is appended to it`s drag container'); | ||
assert.strictEqual(utils.isDraggerEvent(ev), true, 'callback: second argument should be a Dragger event object'); | ||
assert.strictEqual(ev.isFirst, true, 'event.isFirst should be true'); | ||
assert.strictEqual(ev.isFinal, false, 'event.isFinal should be false'); | ||
assert.strictEqual(ev.type, 'start', 'event.type should be "start"'); | ||
++calls; | ||
@@ -34,0 +39,0 @@ }); |
@@ -9,3 +9,3 @@ (function (window) { | ||
assert.expect(5); | ||
assert.expect(8); | ||
@@ -32,4 +32,8 @@ var done = assert.async(); | ||
assert.strictEqual(draggedItem, item, 'callback: first argument should be the dragged item'); | ||
assert.strictEqual(utils.isHammerEvent(ev), true, 'callback: second argument should be a hammer event object'); | ||
assert.strictEqual(isStartCalled, true, 'callback: should be called after dragStart'); | ||
assert.strictEqual(utils.isDraggerEvent(ev), true, 'callback: second argument should be a Dragger event object'); | ||
assert.strictEqual(ev.isFirst, false, 'event.isFirst should be false'); | ||
assert.strictEqual(ev.isFinal, false, 'event.isFinal should be false'); | ||
assert.strictEqual(ev.type, 'move', 'event.type should be "move"'); | ||
} | ||
@@ -36,0 +40,0 @@ ++calls; |
@@ -9,3 +9,3 @@ (function (window) { | ||
assert.expect(6); | ||
assert.expect(9); | ||
@@ -29,5 +29,10 @@ var done = assert.async(); | ||
assert.strictEqual(draggedItem, item, 'callback: first argument should be the dragged item'); | ||
assert.strictEqual(utils.isHammerEvent(ev), true, 'callback: second argument should be a hammer event object'); | ||
assert.strictEqual(utils.matches(draggedItem.getElement(), '.muuri-item-dragging'), true, 'should be called after dragging classname is set'); | ||
assert.strictEqual(draggedItem.getElement().parentNode, document.body, 'should be called after dragged element is appended to it`s drag container'); | ||
assert.strictEqual(utils.isDraggerEvent(ev), true, 'callback: second argument should be a Dragger event object'); | ||
assert.strictEqual(ev.isFirst, true, 'event.isFirst should be true'); | ||
assert.strictEqual(ev.isFinal, false, 'event.isFinal should be false'); | ||
assert.strictEqual(ev.type, 'start', 'event.type should be "start"'); | ||
++calls; | ||
@@ -34,0 +39,0 @@ }); |
@@ -134,4 +134,2 @@ (function (window) { | ||
var items = grid.getItems(); | ||
var showEndItems = null; | ||
var hideEndItems = null; | ||
var teardown = function () { | ||
@@ -138,0 +136,0 @@ grid.destroy(); |
@@ -90,3 +90,2 @@ (function (window) { | ||
var gridB = new Muuri(containerB); | ||
var item = gridA.getItems()[0]; | ||
var gridALayoutId; | ||
@@ -93,0 +92,0 @@ var gridBLayoutId; |
@@ -28,6 +28,9 @@ (function (window) { | ||
grid.once('move', function (data) { | ||
function onMove(data) { | ||
grid.off('move', onMove) | ||
assert.strictEqual(data.action, 'move', 'the movement action should be "move"'); | ||
}); | ||
} | ||
grid.on('move', onMove); | ||
utils.dragElement(item.getElement(), 0, 70, teardown); | ||
@@ -61,6 +64,9 @@ | ||
grid.once('move', function (data) { | ||
function onMove(data) { | ||
grid.off('move', onMove); | ||
assert.strictEqual(data.action, 'swap', 'the movement action should be "swap"'); | ||
}); | ||
} | ||
grid.on('move', onMove); | ||
utils.dragElement(item.getElement(), 0, 70, teardown); | ||
@@ -70,3 +76,3 @@ | ||
QUnit.test('dragSortPredicate: should receive the dragged item and current hammer event as it`s arguments', function (assert) { | ||
QUnit.test('dragSortPredicate: should receive the dragged item and current Dragger event as it`s arguments', function (assert) { | ||
@@ -89,3 +95,3 @@ assert.expect(3); | ||
assert.strictEqual(draggedItem, item, 'predicate first argument should be the dragged item'); | ||
assert.strictEqual(utils.isHammerEvent(ev), true, 'predicate second argument should be a hammer event'); | ||
assert.strictEqual(utils.isDraggerEvent(ev), true, 'predicate second argument should be a Dragger event'); | ||
isChecked = true; | ||
@@ -130,6 +136,9 @@ } | ||
grid.once('move', function () { | ||
function onMove() { | ||
grid.off('move', onMove); | ||
assert.strictEqual(true, false, 'move should not be triggered'); | ||
}); | ||
} | ||
grid.on('move', onMove); | ||
utils.dragElement(item.getElement(), 0, 70, teardown); | ||
@@ -166,7 +175,10 @@ | ||
grid.once('move', function (data) { | ||
function onMove(data) { | ||
grid.off('move', onMove); | ||
assert.strictEqual(data.action, 'swap', 'sort action should be "swap"'); | ||
assert.strictEqual(data.toIndex, grid.getItems().length - 1, 'target index should be the last index'); | ||
}); | ||
} | ||
grid.on('move', onMove); | ||
utils.dragElement(item.getElement(), 0, 70, teardown); | ||
@@ -200,6 +212,9 @@ | ||
grid.once('move', function (data) { | ||
function onMove(data) { | ||
grid.off('move', onMove); | ||
assert.strictEqual(data.action, 'move', 'sort action should be "move"'); | ||
}); | ||
} | ||
grid.on('move', onMove); | ||
utils.dragElement(item.getElement(), 0, 70, teardown); | ||
@@ -236,6 +251,9 @@ | ||
grid.once('move', function (data) { | ||
function onMove(data) { | ||
grid.off('move', onMove); | ||
assert.strictEqual(data.action, 'swap', 'sort action should be "swap"'); | ||
}); | ||
} | ||
grid.on('move', onMove); | ||
utils.dragElement(item.getElement(), 0, 70, teardown); | ||
@@ -242,0 +260,0 @@ |
@@ -7,3 +7,3 @@ (function (window) { | ||
QUnit.test('dragStartPredicate: should receive the dragged item and current hammer event as it`s arguments', function (assert) { | ||
QUnit.test('dragStartPredicate: should receive the dragged item and current Dragger event as it`s arguments', function (assert) { | ||
@@ -21,3 +21,3 @@ assert.expect(3); | ||
assert.strictEqual(draggedItem, item, 'predicate first argument should be the dragged item'); | ||
assert.strictEqual(utils.isHammerEvent(ev), true, 'predicate second argument should be a hammer event'); | ||
assert.strictEqual(utils.isDraggerEvent(ev), true, 'predicate second argument should be a Dragger event'); | ||
isChecked = true; | ||
@@ -60,16 +60,28 @@ } | ||
grid | ||
.once('dragStart', function () { | ||
function onDragStart() { | ||
grid.off('dragStart', onDragStart); | ||
assert.strictEqual(true, true, 'a resolved predicate should start the dragging procedure and trigger dragStart event'); | ||
}) | ||
.once('dragMove', function () { | ||
} | ||
function onDragMove() { | ||
grid.off('dragMove', onDragMove); | ||
assert.strictEqual(true, true, 'a resolved predicate should start the dragging procedure and trigger dragMove event'); | ||
}) | ||
.once('dragEnd', function () { | ||
} | ||
function onDragEnd() { | ||
grid.off('dragEnd', onDragEnd); | ||
assert.strictEqual(true, true, 'a resolved predicate should start the dragging procedure and trigger dragEnd event'); | ||
}) | ||
.once('dragReleaseStart', function () { | ||
} | ||
function onDragReleaseStart() { | ||
grid.off('dragReleaseStart', onDragReleaseStart); | ||
assert.strictEqual(counter, 2, 'predicate should be called twice'); | ||
}); | ||
} | ||
grid | ||
.on('dragStart', onDragStart) | ||
.on('dragMove', onDragMove) | ||
.on('dragEnd', onDragEnd) | ||
.on('dragReleaseStart', onDragReleaseStart); | ||
utils.dragElement(item.getElement(), 0, 70, teardown); | ||
@@ -76,0 +88,0 @@ |
(function (window) { | ||
var Muuri = window.Muuri; | ||
var Simulator = window.Simulator; | ||
@@ -22,13 +21,22 @@ QUnit.module('Item methods'); | ||
grid | ||
.once('dragStart', function () { | ||
function onDragStart() { | ||
grid.off('dragStart', onDragStart); | ||
assert.strictEqual(item.isDragging(), true, 'An item should be in dragging state when dragging starts'); | ||
}) | ||
.once('dragMove', function () { | ||
} | ||
function onDragMove() { | ||
grid.off('dragMove', onDragMove); | ||
assert.strictEqual(item.isDragging(), true, 'An item should be in dragging state when dragging'); | ||
}) | ||
.once('dragEnd', function () { | ||
} | ||
function onDragEnd() { | ||
grid.off('dragEnd', onDragEnd); | ||
assert.strictEqual(item.isDragging(), false, 'An item should not be in dragging state after dragging has ended'); | ||
}); | ||
} | ||
grid | ||
.on('dragStart', onDragStart) | ||
.on('dragMove', onDragMove) | ||
.on('dragEnd', onDragEnd); | ||
assert.strictEqual(item.isDragging(), false, 'An item should not be in dragging state when it`s not being dragged'); | ||
@@ -35,0 +43,0 @@ |
(function (window) { | ||
var Muuri = window.Muuri; | ||
var Simulator = window.Simulator; | ||
@@ -22,20 +21,35 @@ QUnit.module('Item methods'); | ||
grid | ||
.once('dragStart', function () { | ||
function onDragStart() { | ||
grid.off('dragStart', onDragStart); | ||
assert.strictEqual(item.isReleasing(), false, 'An item should not be in releasing state when dragging starts'); | ||
}) | ||
.once('dragMove', function () { | ||
} | ||
function onDragMove() { | ||
grid.off('dragMove', onDragMove); | ||
assert.strictEqual(item.isReleasing(), false, 'An item should not be in releasing state when dragging'); | ||
}) | ||
.once('dragEnd', function () { | ||
} | ||
function onDragEnd() { | ||
grid.off('dragEnd', onDragEnd); | ||
assert.strictEqual(item.isReleasing(), false, 'An item should not be in releasing state when drag ends'); | ||
}) | ||
.once('dragReleaseStart', function () { | ||
} | ||
function onDragReleaseStart() { | ||
grid.off('dragReleaseStart', onDragReleaseStart); | ||
assert.strictEqual(item.isReleasing(), true, 'An item should be in releasing state right after it has been released'); | ||
}) | ||
.once('dragReleaseEnd', function () { | ||
} | ||
function onDragReleaseEnd() { | ||
grid.off('dragReleaseEnd', onDragReleaseEnd); | ||
assert.strictEqual(item.isReleasing(), false, 'An item should not be in releasing state right after releasing has ended'); | ||
teardown(); | ||
}); | ||
} | ||
grid | ||
.on('dragStart', onDragStart) | ||
.on('dragMove', onDragMove) | ||
.on('dragEnd', onDragEnd) | ||
.on('dragReleaseStart', onDragReleaseStart) | ||
.on('dragReleaseEnd', onDragReleaseEnd); | ||
assert.strictEqual(item.isReleasing(), false, 'An item should not be in releasing state when it`s not being released'); | ||
@@ -42,0 +56,0 @@ |
@@ -175,3 +175,3 @@ (function (window) { | ||
utils.isHammerEvent = function (e) { | ||
utils.isDraggerEvent = function (e) { | ||
@@ -182,2 +182,3 @@ var ret = true; | ||
'type', | ||
'srcEvent', | ||
'deltaX', | ||
@@ -187,20 +188,12 @@ 'deltaY', | ||
'distance', | ||
'angle', | ||
'velocityX', | ||
'velocityY', | ||
'velocity', | ||
'direction', | ||
'offsetDirection', | ||
'scale', | ||
'rotation', | ||
'center', | ||
'srcEvent', | ||
'target', | ||
'pointerType', | ||
'eventType', | ||
'isFirst', | ||
'isFinal', | ||
'pointers', | ||
'changedPointers', | ||
'preventDefault' | ||
'identifier', | ||
'screenX', | ||
'screenY', | ||
'clientX', | ||
'clientY', | ||
'pageX', | ||
'pageY', | ||
'target' | ||
]; | ||
@@ -207,0 +200,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
731056
0
22
144
16854
1
2228