magic-grid
Advanced tools
Comparing version 3.0.5 to 3.0.6
@@ -173,7 +173,8 @@ 'use strict'; | ||
var item = this.items[i]; | ||
var topGutter = col.height ? this.gutter : 0; | ||
item.style.left = left + "px"; | ||
item.style.top = col.height + this.gutter + "px"; | ||
item.style.top = col.height + topGutter + "px"; | ||
col.height += item.getBoundingClientRect().height + this.gutter; | ||
col.height += item.getBoundingClientRect().height + topGutter; | ||
} | ||
@@ -180,0 +181,0 @@ |
@@ -171,7 +171,8 @@ /** | ||
var item = this.items[i]; | ||
var topGutter = col.height ? this.gutter : 0; | ||
item.style.left = left + "px"; | ||
item.style.top = col.height + this.gutter + "px"; | ||
item.style.top = col.height + topGutter + "px"; | ||
col.height += item.getBoundingClientRect().height + this.gutter; | ||
col.height += item.getBoundingClientRect().height + topGutter; | ||
} | ||
@@ -178,0 +179,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):t.MagicGrid=i()}(this,function(){"use strict";var t=function(t){t.container||i("container"),t.items||t.static||i("items or static")},i=function(t){throw new Error("Missing property '"+t+"' in MagicGrid config")},e=function(t){var i=t[0];for(var e of t)e.height>i.height&&(i=e);return i},n=function(t){var i=t[0];for(var e of t)e.height<i.height&&(i=e);return i},s=function(i){t(i),this.containerClass=i.container,this.container=document.querySelector(i.container),this.items=this.container.children,this.static=i.static||!1,this.size=i.items,this.gutter=i.gutter||25,this.maxColumns=i.maxColumns||!1,this.useMin=i.useMin||!1,this.animate=i.animate||!1,this.started=!1,this.init()};return s.prototype.init=function(){if(this.ready()&&!this.started){this.container.style.position="relative";for(var t=0;t<this.items.length;t++)this.items[t].style.position="absolute",this.animate&&(this.items[t].style.transition="top,left 0.2s ease");this.started=!0}},s.prototype.colWidth=function(){return this.items[0].getBoundingClientRect().width+this.gutter},s.prototype.setup=function(){var t=this.container.getBoundingClientRect().width,i=Math.floor(t/this.colWidth())||1,e=[];this.maxColumns&&i>this.maxColumns&&(i=this.maxColumns);for(var n=0;n<i;n++)e[n]={height:0,index:n};return{cols:e,wSpace:t-i*this.colWidth()+this.gutter}},s.prototype.nextCol=function(t,i){return this.useMin?n(t):t[i%t.length]},s.prototype.positionItems=function(){var t=this.setup(),i=t.cols,n=t.wSpace;n=Math.floor(n/2);for(var s=0;s<this.items.length;s++){var o=this.nextCol(i,s),r=o.index*this.colWidth()+n,h=this.items[s];h.style.left=r+"px",h.style.top=o.height+this.gutter+"px",o.height+=h.getBoundingClientRect().height+this.gutter}this.container.style.height=e(i).height+"px"},s.prototype.ready=function(){return!!this.static||this.items.length===this.size},s.prototype.getReady=function(){var t=this,i=setInterval(function(){t.container=document.querySelector(t.containerClass),t.items=t.container.children,t.ready()&&(clearInterval(i),t.init(),t.listen())},100)},s.prototype.listen=function(){var t=this;this.ready()?(this.positionItems(),window.addEventListener("resize",function(){setTimeout(t.positionItems(),200)})):this.getReady()},s}); | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):t.MagicGrid=i()}(this,function(){"use strict";var t=function(t){t.container||i("container"),t.items||t.static||i("items or static")},i=function(t){throw new Error("Missing property '"+t+"' in MagicGrid config")},e=function(t){var i=t[0];for(var e of t)e.height>i.height&&(i=e);return i},n=function(t){var i=t[0];for(var e of t)e.height<i.height&&(i=e);return i},s=function(i){t(i),this.containerClass=i.container,this.container=document.querySelector(i.container),this.items=this.container.children,this.static=i.static||!1,this.size=i.items,this.gutter=i.gutter||25,this.maxColumns=i.maxColumns||!1,this.useMin=i.useMin||!1,this.animate=i.animate||!1,this.started=!1,this.init()};return s.prototype.init=function(){if(this.ready()&&!this.started){this.container.style.position="relative";for(var t=0;t<this.items.length;t++)this.items[t].style.position="absolute",this.animate&&(this.items[t].style.transition="top,left 0.2s ease");this.started=!0}},s.prototype.colWidth=function(){return this.items[0].getBoundingClientRect().width+this.gutter},s.prototype.setup=function(){var t=this.container.getBoundingClientRect().width,i=Math.floor(t/this.colWidth())||1,e=[];this.maxColumns&&i>this.maxColumns&&(i=this.maxColumns);for(var n=0;n<i;n++)e[n]={height:0,index:n};return{cols:e,wSpace:t-i*this.colWidth()+this.gutter}},s.prototype.nextCol=function(t,i){return this.useMin?n(t):t[i%t.length]},s.prototype.positionItems=function(){var t=this.setup(),i=t.cols,n=t.wSpace;n=Math.floor(n/2);for(var s=0;s<this.items.length;s++){var o=this.nextCol(i,s),r=o.index*this.colWidth()+n,h=this.items[s],a=o.height?this.gutter:0;h.style.left=r+"px",h.style.top=o.height+a+"px",o.height+=h.getBoundingClientRect().height+a}this.container.style.height=e(i).height+"px"},s.prototype.ready=function(){return!!this.static||this.items.length===this.size},s.prototype.getReady=function(){var t=this,i=setInterval(function(){t.container=document.querySelector(t.containerClass),t.items=t.container.children,t.ready()&&(clearInterval(i),t.init(),t.listen())},100)},s.prototype.listen=function(){var t=this;this.ready()?(this.positionItems(),window.addEventListener("resize",function(){setTimeout(t.positionItems(),200)})):this.getReady()},s}); |
{ | ||
"name": "magic-grid", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "Super lightweight javascript library for dynamic grid layouts.", | ||
@@ -5,0 +5,0 @@ "main": "dist/magic-grid.cjs.js", |
@@ -126,7 +126,8 @@ /** | ||
let item = this.items[i]; | ||
let topGutter = col.height ? this.gutter : 0; | ||
item.style.left = left + "px"; | ||
item.style.top = col.height + this.gutter + "px"; | ||
item.style.top = col.height + topGutter + "px"; | ||
col.height += item.getBoundingClientRect().height + this.gutter; | ||
col.height += item.getBoundingClientRect().height + topGutter; | ||
} | ||
@@ -133,0 +134,0 @@ |
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
24771
670