21 lines
82 KiB
JavaScript
21 lines
82 KiB
JavaScript
|
|
/**
|
||
|
|
* Muuri v0.9.5
|
||
|
|
* https://muuri.dev/
|
||
|
|
* 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 Dragger
|
||
|
|
* Copyright (c) 2018-present, Niklas Rämö <inramo@gmail.com>
|
||
|
|
* @license MIT
|
||
|
|
*
|
||
|
|
* Muuri AutoScroller
|
||
|
|
* Copyright (c) 2019-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="undefined"!=typeof globalThis?globalThis:t||self).Muuri=e()}(this,(function(){"use strict";var t={},e="function"==typeof Map?new Map:null,i="swap",s="move",n="layoutStart",o="layoutEnd",r="layoutAbort",h="remove",a="hideStart",_="filter",l="sort",d="move",u="send",c="beforeSend",f="receive",p="beforeReceive",m="dragReleaseEnd",g="ontouchstart"in window,v=!!window.PointerEvent,y=!!window.navigator.msPointerEnabled;function S(){this._events={},this._queue=[],this._counter=0,this._clearOnEmit=!1}S.prototype.on=function(t,e){if(!this._events||!t||!e)return this;var i=this._events[t];return i||(i=this._events[t]=[]),i.push(e),this},S.prototype.off=function(t,e){if(!this._events||!t||!e)return this;var i,s=this._events[t];if(!s||!s.length)return this;for(;-1!==(i=s.indexOf(e));)s.splice(i,1);return this},S.prototype.clear=function(t){if(!this._events||!t)return this;var e=this._events[t];return e&&(e.length=0,delete this._events[t]),this},S.prototype.emit=function(t){if(!this._events||!t)return this._clearOnEmit=!1,this;var e=this._events[t];if(!e||!e.length)return this._clearOnEmit=!1,this;var i,s=this._queue,n=s.length,o=arguments.length-1;o>3&&((i=[]).push.apply(i,arguments),i.shift()),s.push.apply(s,e),this._clearOnEmit&&(e.length=0,this._clearOnEmit=!1),++this._counter;for(var r=n,h=s.length;r<h;r++)if(0===o?s[r]():1===o?s[r](arguments[1]):2===o?s[r](arguments[1],arguments[2]):3===o?s[r](arguments[1],arguments[2],arguments[3]):s[r].apply(null,i),!this._events)return this;return--this._counter,this._counter||(s.length=0),this},S.prototype.burst=function(){return this._events?(this._clearOnEmit=!0,this.emit.apply(this,arguments),this):this},S.prototype.countListeners=function(t){if(!this._events)return 0;var e=this._events[t];return e?e.length:0},S.prototype.destroy=function(){return this._events?(this._queue.length=this._counter=0,this._events=null,this):this};var w=v?"pointerout":y?"MSPointerOut":"";function D(t){w&&(this._dragger=t,this._timeout=null,this._outEvent=null,this._isActive=!1,this._addBehaviour=this._addBehaviour.bind(this),this._removeBehaviour=this._removeBehaviour.bind(this),this._onTimeout=this._onTimeout.bind(this),this._resetData=this._resetData.bind(this),this._onStart=this._onStart.bind(this),this._onOut=this._onOut.bind(this),this._dragger.on("start",this._onStart))}D.prototype._addBehaviour=function(){this._isActive||(this._isActive=!0,this._dragger.on("move",this._resetData),this._dragger.on("cancel",this._removeBehaviour),this._dragger.on("end",this._removeBehaviour),window.addEventListener(w,this._onOut))},D.prototype._removeBehaviour=function(){this._isActive&&(this._dragger.off("move",this._resetData),this._dragger.off("cancel",this._removeBehaviour),this._dragger.off("end",this._removeBehaviour),window.removeEventListener(w,this._onOut),this._resetData(),this._isActive=!1)},D.prototype._resetData=function(){window.clearTimeout(this._timeout),this._timeout=null,this._outEvent=null},D.prototype._onStart=function(t){"mouse"!==t.pointerType&&this._addBehaviour()},D.prototype._onOut=function(t){this._dragger._getTrackedTouch(t)&&(this._resetData(),this._outEvent=t,this._timeout=window.setTimeout(this._onTimeout,100))},D.prototype._onTimeout=function(){var t=this._outEvent;this._resetData(),this._dragger.isActive()&&this._dragger._onCancel(t)},D.prototype.destroy=function(){w&&(this._dragger.off("start",this._onStart),this._removeBehaviour())};var b=["","webkit","moz","ms","o","Webkit","Moz","MS","O"],A={};function E(t,e){var i=A[e]||"";if(i)return i;for(var s=e[0].toUpperCase()+e.slice(1),n=0;n<b.length;){if((i=b[n]?b[n]+s:e)in t)return A[e]=i,i;++n}return""}function T(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}return t}var x=window.navigator.userAgent.toLowerCase(),k=x.indexOf("edge")>-1,L=x.indexOf("trident")>-1,R=x.ind
|