magic-grid
Advanced tools
Comparing version 3.4.4 to 3.4.5
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).MagicGrid=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function t(e,t,n){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:n;throw new TypeError("Private element is not present on this object")}function n(e,t,n){return t=u(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,c()?Reflect.construct(t,[],u(e).constructor):t.apply(e,n))}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){(function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,n)}function o(e,n,r){return e.set(t(e,n),r),r}function s(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,f(r.key),r)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(t,n){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}(t))||n){r&&(t=r);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var e=r.next();return a=e.done,e},e:function(e){u=!0,s=e},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw s}}}}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(c=function(){return!!e})()}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function f(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function h(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function y(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var p=require("./listener.js"),v=new WeakMap,d=function(){return s((function e(){var t,n,s;r(this,e),t=this,s=void 0,(n=f(n="listeners"))in t?Object.defineProperty(t,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[n]=s,i(this,v,void 0),this.listeners=[],o(v,this,0)}),[{key:"removeListener",value:function(e){var t=this.listeners.findIndex((function(t){return t.id===e}));return-1!==t&&(this.listeners.splice(t,1),!0)}},{key:"addListener",value:function(e,n){var r,i,s,a,u=(o(v,this,(a=this,r=(s=v).get(t(s,a)),i=r++,r)),i);return this.listeners.push(new p(u,e,n)),u}},{key:"emit",value:function(e,t){var n,r=a(this.listeners);try{for(r.s();!(n=r.n()).done;){var i=n.value;i.event===e&&i.handler(t)}}catch(e){r.e(e)}finally{r.f()}}}])}(),m=y(Object.freeze({__proto__:null,default:d})),b=function(e){throw new Error("Missing property '".concat(e,"' in MagicGrid config"))},g=y(Object.freeze({__proto__:null,checkParams:function(e){if(!e)throw new Error("No config object has been provided.");for(var t=0,n=["useTransform","center"];t<n.length;t++){var r=n[t];"boolean"!=typeof e[r]&&(e[r]=!0)}"number"!=typeof e.gutter&&(e.gutter=25),e.container||b("container"),e.items||e.static||b("items or static")},getMin:function(e){var t,n=e[0],r=a(e);try{for(r.s();!(t=r.n()).done;){var i=t.value;i.height<n.height&&(n=i)}}catch(e){r.e(e)}finally{r.f()}return n}})),O=y(Object.freeze({__proto__:null,POSITIONING_COMPLETE_EVENT:"positionComplete",REPOSITIONING_DELAY:200})),w=m,_=g.checkParams,j=g.getMin,P=O.POSITIONING_COMPLETE_EVENT,E=O.REPOSITIONING_DELAY;return h(function(e){function t(e){var i;return r(this,t),i=n(this,t),_(e),e.container instanceof HTMLElement?(i.container=e.container,i.containerClass=e.container.className):(i.containerClass=e.container,i.container=document.querySelector(e.container)),i.static=e.static||!1,i.size=e.items,i.gutter=e.gutter,i.maxColumns=e.maxColumns||!1,i.useMin=e.useMin||!1,i.useTransform=e.useTransform,i.animate=e.animate||!1,i.center=e.center,i.styledItems=new Set,i.resizeObserver=null,i.isPositioning=!1,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&l(e,t)}(t,e),s(t,[{key:"setContainer",value:function(e){var t=this.container;this.container=e,this.resizeObserver.unobserve(t),this.resizeObserver.observe(e)}},{key:"initStyles",value:function(){if(this.ready()){this.container.style.position="relative";for(var e=this.items(),t=0;t<e.length;t++)if(!this.styledItems.has(e[t])){var n=e[t].style;n.position="absolute",this.animate&&(n.transition="".concat(this.useTransform?"transform":"top, left"," 0.2s ease")),this.styledItems.add(e[t])}}}},{key:"items",value:function(){return this.container.children}},{key:"colWidth",value:function(){return this.items()[0].getBoundingClientRect().width+this.gutter}},{key:"setup",value:function(){var e=this.container.getBoundingClientRect().width,t=this.colWidth(),n=Math.floor(e/t)||1,r=[];this.maxColumns&&n>this.maxColumns&&(n=this.maxColumns);for(var i=0;i<n;i++)r[i]={height:0,index:i};return{cols:r,wSpace:e-n*t+this.gutter}}},{key:"nextCol",value:function(e,t){return this.useMin?j(e):e[t%e.length]}},{key:"positionItems",value:function(){if(!this.isPositioning){this.isPositioning=!0;var e=this.setup(),t=e.cols,n=e.wSpace,r=0,i=this.colWidth(),o=this.items();n=this.center?Math.floor(n/2):0,this.initStyles();for(var s=0;s<o.length;s++){var a=this.nextCol(t,s),u=o[s],c=a.height?this.gutter:0,l=a.index*i+n+"px",f=a.height+c+"px";this.useTransform?u.style.transform="translate(".concat(l,", ").concat(f,")"):(u.style.top=f,u.style.left=l),a.height+=u.getBoundingClientRect().height+c,a.height>r&&(r=a.height)}this.container.style.height=r+this.gutter+"px",this.isPositioning=!1,this.emit(P)}}},{key:"ready",value:function(){return!!this.static||this.items().length>=this.size}},{key:"getReady",value:function(){var e=this,t=setInterval((function(){e.container=document.querySelector(e.containerClass),e.ready()&&(clearInterval(t),e.listen())}),100)}},{key:"observeContainerResize",value:function(){var e=this;this.resizeObserver||(this.resizeObserver=new ResizeObserver((function(){setTimeout((function(){e.positionItems()}),E)})),this.resizeObserver.observe(this.container))}},{key:"listen",value:function(){var e=this;this.ready()?(window.addEventListener("resize",(function(){setTimeout((function(){e.positionItems()}),E)})),this.observeContainerResize(),this.positionItems()):this.getReady()}},{key:"onPositionComplete",value:function(e){return this.addListener(P,e)}}])}(w))})); | ||
!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).MagicGrid=e()}(this,(function(){"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function e(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}function n(t,e,n){return e=c(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,l()?Reflect.construct(e,[],c(t).constructor):e.apply(t,n))}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}function o(t,n,i){return t.set(e(t,n),i),i}function s(t,e,n){return e&&function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,h(i.key),i)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function a(e,n){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=function(e,n){if(e){if("string"==typeof e)return t(e,n);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,n):void 0}}(e))||n){i&&(e=i);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,u=!1;return{s:function(){i=i.call(e)},n:function(){var t=i.next();return a=t.done,t},e:function(t){u=!0,s=t},f:function(){try{a||null==i.return||i.return()}finally{if(u)throw s}}}}function u(t,e,n){return(e=h(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function l(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(l=function(){return!!t})()}function f(t,e){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},f(t,e)}function h(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function y(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var v=s((function t(e,n,r){i(this,t),u(this,"id",void 0),u(this,"event",void 0),u(this,"handler",void 0),this.id=e,this.event=n,this.handler=r})),d=v,p=new WeakMap,m=function(){return s((function t(){i(this,t),u(this,"listeners",void 0),r(this,p,void 0),this.listeners=[],o(p,this,0)}),[{key:"removeListener",value:function(t){var e=this.listeners.findIndex((function(e){return e.id===t}));return-1!==e&&(this.listeners.splice(e,1),!0)}},{key:"addListener",value:function(t,n){var i,r,s,a,u=(o(p,this,(a=this,i=(s=p).get(e(s,a)),r=i++,i)),r);return this.listeners.push(new d(u,t,n)),u}},{key:"emit",value:function(t,e){var n,i=a(this.listeners);try{for(i.s();!(n=i.n()).done;){var r=n.value;r.event===t&&r.handler(e)}}catch(t){i.e(t)}finally{i.f()}}}])}(),b=function(t){throw new Error("Missing property '".concat(t,"' in MagicGrid config"))},g=function(t){if(!t)throw new Error("No config object has been provided.");for(var e=0,n=["useTransform","center"];e<n.length;e++){var i=n[e];"boolean"!=typeof t[i]&&(t[i]=!0)}"number"!=typeof t.gutter&&(t.gutter=25),t.container||b("container"),t.items||t.static||b("items or static")},w=function(t){var e,n=t[0],i=a(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;r.height<n.height&&(n=r)}}catch(t){i.e(t)}finally{i.f()}return n},O="positionComplete",j=200;return y(function(t){function e(t){var r;return i(this,e),r=n(this,e),g(t),t.container instanceof HTMLElement?(r.container=t.container,r.containerClass=t.container.className):(r.containerClass=t.container,r.container=document.querySelector(t.container)),r.static=t.static||!1,r.size=t.items,r.gutter=t.gutter,r.maxColumns=t.maxColumns||!1,r.useMin=t.useMin||!1,r.useTransform=t.useTransform,r.animate=t.animate||!1,r.center=t.center,r.styledItems=new Set,r.resizeObserver=null,r.isPositioning=!1,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&f(t,e)}(e,t),s(e,[{key:"setContainer",value:function(t){var e=this.container;this.container=t,this.resizeObserver.unobserve(e),this.resizeObserver.observe(t)}},{key:"initStyles",value:function(){if(this.ready()){this.container.style.position="relative";for(var t=this.items(),e=0;e<t.length;e++)if(!this.styledItems.has(t[e])){var n=t[e].style;n.position="absolute",this.animate&&(n.transition="".concat(this.useTransform?"transform":"top, left"," 0.2s ease")),this.styledItems.add(t[e])}}}},{key:"items",value:function(){return this.container.children}},{key:"colWidth",value:function(){return this.items()[0].getBoundingClientRect().width+this.gutter}},{key:"setup",value:function(){var t=this.container.getBoundingClientRect().width,e=this.colWidth(),n=Math.floor(t/e)||1,i=[];this.maxColumns&&n>this.maxColumns&&(n=this.maxColumns);for(var r=0;r<n;r++)i[r]={height:0,index:r};return{cols:i,wSpace:t-n*e+this.gutter}}},{key:"nextCol",value:function(t,e){return this.useMin?w(t):t[e%t.length]}},{key:"positionItems",value:function(){if(!this.isPositioning){this.isPositioning=!0;var t=this.setup(),e=t.cols,n=t.wSpace,i=0,r=this.colWidth(),o=this.items();n=this.center?Math.floor(n/2):0,this.initStyles();for(var s=0;s<o.length;s++){var a=this.nextCol(e,s),u=o[s],c=a.height?this.gutter:0,l=a.index*r+n+"px",f=a.height+c+"px";this.useTransform?u.style.transform="translate(".concat(l,", ").concat(f,")"):(u.style.top=f,u.style.left=l),a.height+=u.getBoundingClientRect().height+c,a.height>i&&(i=a.height)}this.container.style.height=i+this.gutter+"px",this.isPositioning=!1,this.emit(O)}}},{key:"ready",value:function(){return!!this.static||this.items().length>=this.size}},{key:"getReady",value:function(){var t=this,e=setInterval((function(){t.container=document.querySelector(t.containerClass),t.ready()&&(clearInterval(e),t.listen())}),100)}},{key:"observeContainerResize",value:function(){var t=this;this.resizeObserver||(this.resizeObserver=new ResizeObserver((function(){setTimeout((function(){t.positionItems()}),j)})),this.resizeObserver.observe(this.container))}},{key:"listen",value:function(){var t=this;this.ready()?(window.addEventListener("resize",(function(){setTimeout((function(){t.positionItems()}),j)})),this.observeContainerResize(),this.positionItems()):this.getReady()}},{key:"onPositionComplete",value:function(t){return this.addListener(O,t)}}])}(m))})); |
{ | ||
"name": "magic-grid", | ||
"version": "3.4.4", | ||
"version": "3.4.5", | ||
"description": "Super lightweight javascript library for dynamic grid layouts.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
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
0
40370
600