From 4917107b7d6b57c991f2f6e2a35142966682f496 Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Thu, 29 Aug 2013 22:39:02 -0400 Subject: [PATCH] add masonry horizontal stamps --- examples/masonry-horizontal.html | 26 +++++++++++++++++++++++++- layout-modes/masonry-horizontal.js | 8 ++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/examples/masonry-horizontal.html b/examples/masonry-horizontal.html index 5386989..d20fb75 100644 --- a/examples/masonry-horizontal.html +++ b/examples/masonry-horizontal.html @@ -20,6 +20,27 @@ .element.lanthanoid { height: 190px; } .element.actinoid { width: 170px; } .element.transition { width: 220px; } + + .stamp { + background: #DDD; + border: 2px dotted; + position: absolute; + } + + .stamp1 { + height: 30%; + width: 80px; + left: 30px; + top: 10%; + } + + .stamp2 { + height: 200px; + width: 40px; + left: 15px; + top: 100px; + } + @@ -45,6 +66,9 @@
+
+
+

80

@@ -175,7 +199,7 @@ docReady( function() { var container = document.querySelector('#container'); var iso = window.iso = new Isotope( container, { itemSelector: '.element', - // stamp: '.stamp', + stamp: '.stamp', layoutMode: 'masonryHorizontal', transitionDuration: '0.8s', masonryHorizontal: { diff --git a/layout-modes/masonry-horizontal.js b/layout-modes/masonry-horizontal.js index 383e717..13a6e68 100644 --- a/layout-modes/masonry-horizontal.js +++ b/layout-modes/masonry-horizontal.js @@ -95,16 +95,16 @@ function masonryHorizontalDefinition( getSize, layoutMode ) { MasonryHorizontal.prototype._manageStamp = function( stamp ) { var stampSize = getSize( stamp ); - var offset = this._getElementOffset( stamp ); + var offset = this.isotope._getElementOffset( stamp ); // get the rows that this stamp affects - var firstY = this.options.isOriginTop ? offset.top : offset.bottom; + var firstY = this.isotope.options.isOriginTop ? offset.top : offset.bottom; var lastY = firstY + stampSize.outerHeight; var firstRow = Math.floor( firstY / this.rowHeight ); firstRow = Math.max( 0, firstRow ); var lastRow = Math.floor( lastY / this.rowHeight ); lastRow = Math.min( this.rows - 1, lastRow ); - // set rowXs to bottom of the stamp - var stampMaxX = ( this.options.isOriginLeft ? offset.left : offset.right ) + + // set rowXs to outside edge of the stamp + var stampMaxX = ( this.isotope.options.isOriginLeft ? offset.left : offset.right ) + stampSize.outerWidth; for ( var i = firstRow; i <= lastRow; i++ ) { this.rowXs[i] = Math.max( stampMaxX, this.rowXs[i] );