web-assets/shuffle/v6/shuffle.min.js

3 lines
17 KiB
JavaScript
Raw Permalink Normal View History

2024-01-20 21:00:51 +01:00
!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).Shuffle=e()}(this,(function(){"use strict";var t={exports:{}};function e(){}e.prototype={on:function(t,e,i){var s=this.e||(this.e={});return(s[t]||(s[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var s=this;function n(){s.off(t,n),e.apply(i,arguments)}return n._=e,this.on(t,n,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),s=0,n=i.length;s<n;s++)i[s].fn.apply(i[s].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),s=i[t],n=[];if(s&&e)for(var o=0,r=s.length;o<r;o++)s[o].fn!==e&&s[o].fn._!==e&&n.push(s[o]);return n.length?i[t]=n:delete i[t],this}},t.exports=e,t.exports.TinyEmitter=e;function i(){}function s(t){return parseFloat(t)||0}class n{constructor(t,e){this.x=s(t),this.y=s(e)}static equals(t,e){return t.x===e.x&&t.y===e.y}}class o{constructor(t,e,i,s,n){this.id=n,this.left=t,this.top=e,this.width=i,this.height=s}static intersects(t,e){return t.left<e.left+e.width&&e.left<t.left+t.width&&t.top<e.top+e.height&&e.top<t.top+t.height}}var r={BASE:"shuffle",SHUFFLE_ITEM:"shuffle-item",VISIBLE:"shuffle-item--visible",HIDDEN:"shuffle-item--hidden"};let h=0;class l{constructor(t,e){h+=1,this.id=h,this.element=t,this.isRTL=e,this.isVisible=!0,this.isHidden=!1}show(){this.isVisible=!0,this.element.classList.remove(r.HIDDEN),this.element.classList.add(r.VISIBLE),this.element.removeAttribute("aria-hidden")}hide(){this.isVisible=!1,this.element.classList.remove(r.VISIBLE),this.element.classList.add(r.HIDDEN),this.element.setAttribute("aria-hidden",!0)}init(){this.addClasses([r.SHUFFLE_ITEM,r.VISIBLE]),this.applyCss(l.Css.INITIAL),this.applyCss(this.isRTL?l.Css.DIRECTION.rtl:l.Css.DIRECTION.ltr),this.scale=l.Scale.VISIBLE,this.point=new n}addClasses(t){t.forEach((t=>{this.element.classList.add(t)}))}removeClasses(t){t.forEach((t=>{this.element.classList.remove(t)}))}applyCss(t){Object.keys(t).forEach((e=>{this.element.style[e]=t[e]}))}dispose(){this.removeClasses([r.HIDDEN,r.VISIBLE,r.SHUFFLE_ITEM]),this.element.removeAttribute("style"),this.element=null}}l.Css={INITIAL:{position:"absolute",top:0,visibility:"visible",willChange:"transform"},DIRECTION:{ltr:{left:0},rtl:{right:0}},VISIBLE:{before:{opacity:1,visibility:"visible"},after:{transitionDelay:""}},HIDDEN:{before:{opacity:0},after:{visibility:"hidden",transitionDelay:""}}},l.Scale={VISIBLE:1,HIDDEN:.001};let a=null;var d=()=>{if(null!==a)return a;const t=document.body||document.documentElement,e=document.createElement("div");e.style.cssText="width:10px;padding:2px;box-sizing:border-box;",t.appendChild(e);const{width:i}=window.getComputedStyle(e,null);return a=10===Math.round(s(i)),t.removeChild(e),a};function u(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window.getComputedStyle(t,null),n=s(i[e]);return d()||"width"!==e?d()||"height"!==e||(n+=s(i.paddingTop)+s(i.paddingBottom)+s(i.borderTopWidth)+s(i.borderBottomWidth)):n+=s(i.paddingLeft)+s(i.paddingRight)+s(i.borderLeftWidth)+s(i.borderRightWidth),n}const m={reverse:!1,by:null,compare:null,randomize:!1,key:"element"};function c(t,e){const i={...m,...e},s=Array.from(t);let n=!1;return t.length?i.randomize?function(t){let e=t.length;for(;e;){e-=1;const i=Math.floor(Math.random()*(e+1)),s=t[i];t[i]=t[e],t[e]=s}return t}(t):("function"==typeof i.by?t.sort(((t,e)=>{if(n)return 0;const s=i.by(t[i.key]),o=i.by(e[i.key]);return void 0===s&&void 0===o?(n=!0,0):s<o||"sortFirst"===s||"sortLast"===o?-1:s>o||"sortLast"===s||"sortFirst"===o?1:0})):"function"==typeof i.compare&&t.sort(i.compare),n?s:(i.reverse&&t.reverse(),t)):[]}const p={},f="transitionend";let g=0;function _(t){return!!p[t]&&(p[t].element.removeEventListener(f,p[t].listener),p[t]=null,!0)}function y(t,e){const i=(g+=1,f+g),s=t=>{t.currentTarget===t.target&&(_(i),e(t))};return t.addEventListener(f,s),p[i]={element:t,listener:s},i}function I(t){return Math.max(...t)}function E(t,e,i,s){let n=t/
//# sourceMappingURL=shuffle.min.js.map