Browse Source

👷 build v3.0.4 for masonry horizontalOrder

🔔 update Masonry v4.2.0 with horizontalOrder. For #1130
⬆️ Update fizzy-ui-utils to v2.0.5
📦 add package.json files
pull/694/merge v3.0.4
David DeSandro 8 years ago
parent
commit
737e8329b0
  1. 96
      dist/isotope.pkgd.js
  2. 6
      dist/isotope.pkgd.min.js
  3. 2
      js/isotope.js
  4. 8
      package.json
  5. 3
      sandbox/masonry.html

96
dist/isotope.pkgd.js vendored

@ -1,5 +1,5 @@
/*! /*!
* Isotope PACKAGED v3.0.3 * Isotope PACKAGED v3.0.4
* *
* Licensed GPLv3 for open source use * Licensed GPLv3 for open source use
* or Isotope Commercial License for commercial use * or Isotope Commercial License for commercial use
@ -527,7 +527,7 @@ return getSize;
})); }));
/** /**
* Fizzy UI utils v2.0.4 * Fizzy UI utils v2.0.5
* MIT license * MIT license
*/ */
@ -613,7 +613,7 @@ utils.removeFrom = function( ary, obj ) {
// ----- getParent ----- // // ----- getParent ----- //
utils.getParent = function( elem, selector ) { utils.getParent = function( elem, selector ) {
while ( elem != document.body ) { while ( elem.parentNode && elem != document.body ) {
elem = elem.parentNode; elem = elem.parentNode;
if ( matchesSelector( elem, selector ) ) { if ( matchesSelector( elem, selector ) ) {
return elem; return elem;
@ -2496,7 +2496,7 @@ return Item;
})); }));
/*! /*!
* Masonry v4.1.1 * Masonry v4.2.0
* Cascading grid layout library * Cascading grid layout library
* http://masonry.desandro.com * http://masonry.desandro.com
* MIT License * MIT License
@ -2538,7 +2538,9 @@ return Item;
// isFitWidth -> fitWidth // isFitWidth -> fitWidth
Masonry.compatOptions.fitWidth = 'isFitWidth'; Masonry.compatOptions.fitWidth = 'isFitWidth';
Masonry.prototype._resetLayout = function() { var proto = Masonry.prototype;
proto._resetLayout = function() {
this.getSize(); this.getSize();
this._getMeasurement( 'columnWidth', 'outerWidth' ); this._getMeasurement( 'columnWidth', 'outerWidth' );
this._getMeasurement( 'gutter', 'outerWidth' ); this._getMeasurement( 'gutter', 'outerWidth' );
@ -2551,9 +2553,10 @@ return Item;
} }
this.maxY = 0; this.maxY = 0;
this.horizontalColIndex = 0;
}; };
Masonry.prototype.measureColumns = function() { proto.measureColumns = function() {
this.getContainerWidth(); this.getContainerWidth();
// if columnWidth is 0, default to outerWidth of first item // if columnWidth is 0, default to outerWidth of first item
if ( !this.columnWidth ) { if ( !this.columnWidth ) {
@ -2578,7 +2581,7 @@ return Item;
this.cols = Math.max( cols, 1 ); this.cols = Math.max( cols, 1 );
}; };
Masonry.prototype.getContainerWidth = function() { proto.getContainerWidth = function() {
// container is parent if fit width // container is parent if fit width
var isFitWidth = this._getOption('fitWidth'); var isFitWidth = this._getOption('fitWidth');
var container = isFitWidth ? this.element.parentNode : this.element; var container = isFitWidth ? this.element.parentNode : this.element;
@ -2588,7 +2591,7 @@ return Item;
this.containerWidth = size && size.innerWidth; this.containerWidth = size && size.innerWidth;
}; };
Masonry.prototype._getItemLayoutPosition = function( item ) { proto._getItemLayoutPosition = function( item ) {
item.getSize(); item.getSize();
// how many columns does this brick span // how many columns does this brick span
var remainder = item.size.outerWidth % this.columnWidth; var remainder = item.size.outerWidth % this.columnWidth;
@ -2596,33 +2599,41 @@ return Item;
// round if off by 1 pixel, otherwise use ceil // round if off by 1 pixel, otherwise use ceil
var colSpan = Math[ mathMethod ]( item.size.outerWidth / this.columnWidth ); var colSpan = Math[ mathMethod ]( item.size.outerWidth / this.columnWidth );
colSpan = Math.min( colSpan, this.cols ); colSpan = Math.min( colSpan, this.cols );
// use horizontal or top column position
var colGroup = this._getColGroup( colSpan ); var colPosMethod = this.options.horizontalOrder ?
// get the minimum Y value from the columns '_getHorizontalColPosition' : '_getTopColPosition';
var minimumY = Math.min.apply( Math, colGroup ); var colPosition = this[ colPosMethod ]( colSpan, item );
var shortColIndex = colGroup.indexOf( minimumY );
// position the brick // position the brick
var position = { var position = {
x: this.columnWidth * shortColIndex, x: this.columnWidth * colPosition.col,
y: minimumY y: colPosition.y
}; };
// apply setHeight to necessary columns // apply setHeight to necessary columns
var setHeight = minimumY + item.size.outerHeight; var setHeight = colPosition.y + item.size.outerHeight;
var setSpan = this.cols + 1 - colGroup.length; var setMax = colSpan + colPosition.col;
for ( var i = 0; i < setSpan; i++ ) { for ( var i = colPosition.col; i < setMax; i++ ) {
this.colYs[ shortColIndex + i ] = setHeight; this.colYs[i] = setHeight;
} }
return position; return position;
}; };
proto._getTopColPosition = function( colSpan ) {
var colGroup = this._getTopColGroup( colSpan );
// get the minimum Y value from the columns
var minimumY = Math.min.apply( Math, colGroup );
return {
col: colGroup.indexOf( minimumY ),
y: minimumY,
};
};
/** /**
* @param {Number} colSpan - number of columns the element spans * @param {Number} colSpan - number of columns the element spans
* @returns {Array} colGroup * @returns {Array} colGroup
*/ */
Masonry.prototype._getColGroup = function( colSpan ) { proto._getTopColGroup = function( colSpan ) {
if ( colSpan < 2 ) { if ( colSpan < 2 ) {
// if brick spans only one column, use all the column Ys // if brick spans only one column, use all the column Ys
return this.colYs; return this.colYs;
@ -2633,15 +2644,38 @@ return Item;
var groupCount = this.cols + 1 - colSpan; var groupCount = this.cols + 1 - colSpan;
// for each group potential horizontal position // for each group potential horizontal position
for ( var i = 0; i < groupCount; i++ ) { for ( var i = 0; i < groupCount; i++ ) {
// make an array of colY values for that one group colGroup[i] = this._getColGroupY( i, colSpan );
var groupColYs = this.colYs.slice( i, i + colSpan );
// and get the max value of the array
colGroup[i] = Math.max.apply( Math, groupColYs );
} }
return colGroup; return colGroup;
}; };
Masonry.prototype._manageStamp = function( stamp ) { proto._getColGroupY = function( col, colSpan ) {
if ( colSpan < 2 ) {
return this.colYs[ col ];
}
// make an array of colY values for that one group
var groupColYs = this.colYs.slice( col, col + colSpan );
// and get the max value of the array
return Math.max.apply( Math, groupColYs );
};
// get column position based on horizontal index. #873
proto._getHorizontalColPosition = function( colSpan, item ) {
var col = this.horizontalColIndex % this.cols;
var isOver = colSpan > 1 && col + colSpan > this.cols;
// shift to next row if item can't fit on current row
col = isOver ? 0 : col;
// don't let zero-size items take up space
var hasSize = item.size.outerWidth && item.size.outerHeight;
this.horizontalColIndex = hasSize ? col + colSpan : this.horizontalColIndex;
return {
col: col,
y: this._getColGroupY( col, colSpan ),
};
};
proto._manageStamp = function( stamp ) {
var stampSize = getSize( stamp ); var stampSize = getSize( stamp );
var offset = this._getElementOffset( stamp ); var offset = this._getElementOffset( stamp );
// get the columns that this stamp affects // get the columns that this stamp affects
@ -2664,7 +2698,7 @@ return Item;
} }
}; };
Masonry.prototype._getContainerSize = function() { proto._getContainerSize = function() {
this.maxY = Math.max.apply( Math, this.colYs ); this.maxY = Math.max.apply( Math, this.colYs );
var size = { var size = {
height: this.maxY height: this.maxY
@ -2677,7 +2711,7 @@ return Item;
return size; return size;
}; };
Masonry.prototype._getContainerFitWidth = function() { proto._getContainerFitWidth = function() {
var unusedCols = 0; var unusedCols = 0;
// count unused columns // count unused columns
var i = this.cols; var i = this.cols;
@ -2691,7 +2725,7 @@ return Item;
return ( this.cols - unusedCols ) * this.columnWidth - this.gutter; return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
}; };
Masonry.prototype.needsResizeLayout = function() { proto.needsResizeLayout = function() {
var previousWidth = this.containerWidth; var previousWidth = this.containerWidth;
this.getContainerWidth(); this.getContainerWidth();
return previousWidth != this.containerWidth; return previousWidth != this.containerWidth;
@ -2901,7 +2935,7 @@ return Vertical;
})); }));
/*! /*!
* Isotope v3.0.3 * Isotope v3.0.4
* *
* Licensed GPLv3 for open source use * Licensed GPLv3 for open source use
* or Isotope Commercial License for commercial use * or Isotope Commercial License for commercial use

6
dist/isotope.pkgd.min.js vendored

File diff suppressed because one or more lines are too long

2
js/isotope.js

@ -1,5 +1,5 @@
/*! /*!
* Isotope v3.0.3 * Isotope v3.0.4
* *
* Licensed GPLv3 for open source use * Licensed GPLv3 for open source use
* or Isotope Commercial License for commercial use * or Isotope Commercial License for commercial use

8
package.json

@ -1,13 +1,17 @@
{ {
"name": "isotope-layout", "name": "isotope-layout",
"version": "3.0.3", "version": "3.0.4",
"description": "Filter and sort magical layouts", "description": "Filter and sort magical layouts",
"main": "js/isotope.js", "main": "js/isotope.js",
"files": [
"js",
"dist"
],
"dependencies": { "dependencies": {
"desandro-matches-selector": "^2.0.0", "desandro-matches-selector": "^2.0.0",
"fizzy-ui-utils": "^2.0.4", "fizzy-ui-utils": "^2.0.4",
"get-size": "^2.0.0", "get-size": "^2.0.0",
"masonry-layout": "^4.0.0", "masonry-layout": "^4.1.0",
"outlayer": "^2.1.0" "outlayer": "^2.1.0"
}, },
"devDependencies": { "devDependencies": {

3
sandbox/masonry.html

@ -167,7 +167,8 @@ var iso = window.iso = new Isotope( container, {
// filter: '.metal', // filter: '.metal',
layoutMode: 'masonry', layoutMode: 'masonry',
masonry: { masonry: {
columnWidth: 90 columnWidth: 90,
// horizontalOrder: true,
}, },
itemSelector: '.element', itemSelector: '.element',
stamp: '.stamp', stamp: '.stamp',

Loading…
Cancel
Save