@@ -5,7 +5,8 @@ var MiniMasonry = function(conf) {
55 this . _count = null ;
66 this . _width = 0 ;
77 this . _removeListener = null ;
8- this . _savedGutterX = null ;
8+ this . _currentGutterX = null ;
9+ this . _currentGutterY = null ;
910
1011 this . _resizeTimeout = null ,
1112
@@ -33,9 +34,12 @@ MiniMasonry.prototype.init = function(conf) {
3334 this . conf [ i ] = conf [ i ] ;
3435 }
3536 }
37+
3638 if ( this . conf . gutterX == null || this . conf . gutterY == null ) {
37- this . _savedGutterX = this . conf . gutterX = this . conf . gutterY = this . conf . gutter ;
39+ this . conf . gutterX = this . conf . gutterY = this . conf . gutter ;
3840 }
41+ this . _currentGutterX = this . conf . gutterX ;
42+ this . _currentGutterY = this . conf . gutterY ;
3943
4044 this . _container = typeof this . conf . container == 'object' && this . conf . container . nodeName ?
4145 this . conf . container :
@@ -67,31 +71,31 @@ MiniMasonry.prototype.reset = function() {
6771
6872 if ( this . getCount ( ) == 1 ) {
6973 // Set ultimate gutter when only one column is displayed
70- this . conf . gutterX = this . conf . ultimateGutter ;
74+ this . _currentGutterX = this . conf . ultimateGutter ;
7175 // As gutters are reduced, two column may fit, forcing to 1
7276 this . _count = 1 ;
73- } else if ( this . _width < ( this . conf . baseWidth + ( 2 * this . conf . gutterX ) ) ) {
77+ } else if ( this . _width < ( this . conf . baseWidth + ( 2 * this . _currentGutterX ) ) ) {
7478 // Remove gutter when screen is to low
75- this . conf . gutterX = 0 ;
79+ this . _currentGutterX = 0 ;
7680 } else {
77- this . conf . gutterX = this . _savedGutterX
81+ this . _currentGutterX = this . conf . gutterX ;
7882 }
7983} ;
8084
8185MiniMasonry . prototype . getCount = function ( ) {
8286 if ( this . conf . surroundingGutter ) {
83- return Math . floor ( ( this . _width - this . conf . gutterX ) / ( this . conf . baseWidth + this . conf . gutterX ) ) ;
87+ return Math . floor ( ( this . _width - this . _currentGutterX ) / ( this . conf . baseWidth + this . _currentGutterX ) ) ;
8488 }
8589
86- return Math . floor ( ( this . _width + this . conf . gutterX ) / ( this . conf . baseWidth + this . conf . gutterX ) ) ;
90+ return Math . floor ( ( this . _width + this . _currentGutterX ) / ( this . conf . baseWidth + this . _currentGutterX ) ) ;
8791}
8892
8993MiniMasonry . prototype . computeWidth = function ( ) {
9094 var width ;
9195 if ( this . conf . surroundingGutter ) {
92- width = ( ( this . _width - this . conf . gutterX ) / this . _count ) - this . conf . gutterX ;
96+ width = ( ( this . _width - this . _currentGutterX ) / this . _count ) - this . _currentGutterX ;
9397 } else {
94- width = ( ( this . _width + this . conf . gutterX ) / this . _count ) - this . conf . gutterX ;
98+ width = ( ( this . _width + this . _currentGutterX ) / this . _count ) - this . _currentGutterX ;
9599 }
96100 width = Number . parseFloat ( width . toFixed ( 2 ) ) ;
97101
@@ -126,13 +130,13 @@ MiniMasonry.prototype.layout = function() {
126130
127131 var startX ;
128132 if ( this . conf . direction == 'ltr' ) {
129- startX = this . conf . surroundingGutter ? this . conf . gutterX : 0 ;
133+ startX = this . conf . surroundingGutter ? this . _currentGutterX : 0 ;
130134 } else {
131- startX = this . _width - ( this . conf . surroundingGutter ? this . conf . gutterX : 0 ) ;
135+ startX = this . _width - ( this . conf . surroundingGutter ? this . _currentGutterX : 0 ) ;
132136 }
133137 if ( this . _count > this . _sizes . length ) {
134138 //If more columns than children
135- var occupiedSpace = ( this . _sizes . length * ( colWidth + this . conf . gutterX ) ) - this . conf . gutterX ;
139+ var occupiedSpace = ( this . _sizes . length * ( colWidth + this . _currentGutterX ) ) - this . _currentGutterX ;
136140 if ( this . conf . wedge === false ) {
137141 if ( this . conf . direction == 'ltr' ) {
138142 startX = ( ( this . _width - occupiedSpace ) / 2 ) ;
@@ -143,7 +147,7 @@ MiniMasonry.prototype.layout = function() {
143147 if ( this . conf . direction == 'ltr' ) {
144148 //
145149 } else {
146- startX = this . _width - this . conf . gutterX ;
150+ startX = this . _width - this . _currentGutterX ;
147151 }
148152 }
149153 }
@@ -154,7 +158,7 @@ MiniMasonry.prototype.layout = function() {
154158
155159 var childrenGutter = 0 ;
156160 if ( this . conf . surroundingGutter || nextColumn != this . _columns . length ) {
157- childrenGutter = this . conf . gutterX ;
161+ childrenGutter = this . _currentGutterX ;
158162 }
159163 var x ;
160164 if ( this . conf . direction == 'ltr' ) {
@@ -170,7 +174,7 @@ MiniMasonry.prototype.layout = function() {
170174 this . _columns [ nextColumn ] += this . _sizes [ index ] + ( this . _count > 1 ? this . conf . gutterY : this . conf . ultimateGutter ) ; //margin-bottom
171175 }
172176
173- this . _container . style . height = ( this . _columns [ this . getLongest ( ) ] - this . conf . gutterY ) + 'px' ;
177+ this . _container . style . height = ( this . _columns [ this . getLongest ( ) ] - this . _currentGutterY ) + 'px' ;
174178} ;
175179
176180MiniMasonry . prototype . getNextColumn = function ( index ) {
0 commit comments