From fda4910b2faf4c73f6d15b1e6b977f1a9c3b4779 Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Wed, 16 Oct 2013 21:05:04 -0400 Subject: [PATCH] test layoutMode.getSegmentSize --- js/layout-mode.js | 2 +- test/get-segment-size.js | 38 ++++++++++++++++++++++++++++++++++++++ test/index.html | 9 +++++++++ test/tests.css | 11 +++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 test/get-segment-size.js diff --git a/js/layout-mode.js b/js/layout-mode.js index a9d1a8e..599583d 100644 --- a/js/layout-mode.js +++ b/js/layout-mode.js @@ -88,7 +88,7 @@ function layoutModeDefinition( getSize, Outlayer ) { } // fall back to item of first element var firstItemSize = this.getFirstItemSize(); - this.rowHeight = firstItemSize && firstItemSize[ outerSize ] || + this[ segmentName ] = firstItemSize && firstItemSize[ outerSize ] || // or size of container this.isotope.size[ 'inner' + size ]; }; diff --git a/test/get-segment-size.js b/test/get-segment-size.js new file mode 100644 index 0000000..a6ed450 --- /dev/null +++ b/test/get-segment-size.js @@ -0,0 +1,38 @@ +( function() { + +'use strict'; + +test( 'LayoutMode.getSegmentSize', function() { + + var iso = new Isotope( '#get-segment-size', { + layoutMode: 'cellsByRow', + itemSelector: '.item', + cellsByRow: { + columnWidth: 17, + rowHeight: 23 + } + }); + + var cellsByRow = iso.modes.cellsByRow; + equal( cellsByRow.columnWidth, 17, 'explicit columnWidth option set' ); + equal( cellsByRow.rowHeight, 23, 'explicit rowHeight option set' ); + + // set element sizing + iso.options.cellsByRow.columnWidth = '.grid-sizer'; + iso.options.cellsByRow.rowHeight = '.grid-sizer'; + cellsByRow.getColumnWidth(); + cellsByRow.getRowHeight(); + equal( cellsByRow.columnWidth, 57, 'element sizing columnWidth' ); + equal( cellsByRow.rowHeight, 47, 'element sizing rowHeight' ); + + // default to first item + delete iso.options.cellsByRow.columnWidth; + delete iso.options.cellsByRow.rowHeight; + cellsByRow.getColumnWidth(); + cellsByRow.getRowHeight(); + equal( cellsByRow.columnWidth, 60, 'first item columnWidth' ); + equal( cellsByRow.rowHeight, 30, 'first item rowHeight' ); + +}); + +})(); diff --git a/test/index.html b/test/index.html index 89221ff..5e1f8c1 100644 --- a/test/index.html +++ b/test/index.html @@ -26,10 +26,12 @@ + + @@ -74,5 +76,12 @@
a3 b3
+

LayoutMode.getSegmentSize

+ +
+
+
+
+ diff --git a/test/tests.css b/test/tests.css index 18f3027..b40dd19 100644 --- a/test/tests.css +++ b/test/tests.css @@ -59,3 +59,14 @@ body { width: 200px; height: 20px; } + +/* ---- get segment size ---- */ + +#get-segment-size .grid-sizer { + /* 57 outer width */ + width: 52px; + margin-right: 5px; + /* 47 outer height */ + height: 40px; + margin-bottom: 7px; +}