diff --git a/examples/cells-by-row.html b/examples/cells-by-row.html
new file mode 100644
index 0000000..0c12b39
--- /dev/null
+++ b/examples/cells-by-row.html
@@ -0,0 +1,214 @@
+
+
+
+
+
+ masonry
+
+
+
+
+
+
+
+ sorting
+
+
+
+
+
+
+
+
+
+
+
83
+
Bi
+
Bismuth
+
208.9804
+
+
+
+
+
+
+
+
+
+
81
+
Tl
+
Thallium
+
204.3833
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/layout-mode.js b/layout-mode.js
index e1e3daa..2895fa8 100644
--- a/layout-mode.js
+++ b/layout-mode.js
@@ -4,8 +4,6 @@
// -------------------------- -------------------------- //
-// var Isotope = window.Isotope;
-
function layoutModeDefinition( Outlayer ) {
var layoutMode = {};
@@ -13,6 +11,7 @@ var layoutMode = {};
layoutMode.modes = {};
layoutMode.create = function( namespace, options ) {
+ // layout mode class
function LayoutMode( isotope ) {
this.isotope = isotope;
// link properties
diff --git a/layout-modes/cells-by-row.js b/layout-modes/cells-by-row.js
new file mode 100644
index 0000000..4d9ec9b
--- /dev/null
+++ b/layout-modes/cells-by-row.js
@@ -0,0 +1,81 @@
+( function( window ) {
+
+'use strict';
+
+function cellsByRowDefinition( layoutMode, getSize ) {
+
+ var CellsByRow = layoutMode.create( 'cellsByRow' );
+
+ var __resetLayout = CellsByRow.prototype._resetLayout;
+
+ CellsByRow.prototype._resetLayout = function() {
+ // call super
+ __resetLayout.call( this );
+ var containerSize = this.isotope.size;
+ this.itemIndex = 0;
+
+ this._getMeasurement( 'columnWidth', 'outerWidth' );
+ this._getMeasurement( 'rowHeight', 'outerHeight' );
+
+ var firstItem = this.items[0];
+ var firstItemSize = firstItem && firstItem.element && getSize( firstItem.element );
+
+ if ( !this.columnWidth ) {
+ // columnWidth fall back to item of first element
+ this.columnWidth = firstItemSize ? firstItemSize.outerWidth :
+ // or size of container
+ containerSize.innerWidth;
+ }
+
+ if ( !this.rowHeight ) {
+ // rowHeight fall back to item of first element
+ this.rowHeight = firstItemSize ? firstItemSize.outerHeight :
+ // or size of container
+ containerSize.innerHeight;
+ }
+
+ this.cols = Math.floor( containerSize.innerWidth / this.columnWidth );
+ this.cols = Math.max( this.cols, 1 );
+
+ };
+
+ CellsByRow.prototype._getItemLayoutPosition = function( item ) {
+ item.getSize();
+ var col = this.itemIndex % this.cols;
+ var row = Math.floor( this.itemIndex / this.cols );
+ // center item within cell
+ var x = ( col + 0.5 ) * this.columnWidth - item.size.outerWidth / 2;
+ var y = ( row + 0.5 ) * this.rowHeight - item.size.outerHeight / 2;
+ this.itemIndex++;
+ return { x: x, y: y };
+ };
+
+ CellsByRow.prototype._getContainerSize = function() {
+ return {
+ height: ( this.itemIndex / this.cols ) * this.rowHeight
+ };
+ };
+
+ return CellsByRow;
+
+}
+
+if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( [
+ '../layout-mode',
+ 'get-size/get-size'
+ ],
+ cellsByRowDefinition );
+} else {
+ // browser global
+ cellsByRowDefinition(
+ window.Isotope.layoutMode,
+ window.getSize
+ );
+}
+
+
+})( window );
+
+