Skip to content

Commit

Permalink
options isOriginLeft/Top
Browse files Browse the repository at this point in the history
  • Loading branch information
desandro committed May 25, 2013
1 parent 8ea3797 commit 70a5dc1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
31 changes: 9 additions & 22 deletions masonry.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,9 @@ var indexOf = Array.prototype.indexOf ?
function masonryDefinition( Outlayer, getSize ) {
// create an Outlayer layout class
var Masonry = Outlayer.create('masonry');
// default options
var defaultOptions = Masonry.prototype.options;
defaultOptions.isOriginLeft = true;
defaultOptions.isOriginTop = true;

Masonry.prototype._resetLayout = function() {
this.getSize();
this.isOriginLeft = this.options.isOriginLeft;
this.isOriginTop = this.options.isOriginTop;
this._getMeasurement( 'columnWidth', 'outerWidth' );
this._getMeasurement( 'gutter', 'outerWidth' );
this.measureColumns();
Expand Down Expand Up @@ -95,18 +89,6 @@ function masonryDefinition( Outlayer, getSize ) {
return position;
};

Masonry.prototype._postLayout = function() {
this.maxY = Math.max.apply( Math, this.colYs );

var elemH = this.maxY;
// add padding and border width if border box
if ( this.size.isBorderBox ) {
elemH += this.size.paddingBottom + this.size.paddingTop +
this.size.borderTopWidth + this.size.borderBottomWidth;
}
this.element.style.height = elemH + 'px';
};

/**
* @param {Number} colSpan - number of columns the element spans
* @returns {Array} colGroup
Expand All @@ -130,18 +112,16 @@ function masonryDefinition( Outlayer, getSize ) {
return colGroup;
};

// ----- stamps ----- //

Masonry.prototype._manageStamp = function( stamp ) {
var stampSize = getSize( stamp );
var offset = this._getElementOffset( stamp );
// get the columns that this stamp affects
var firstX = this.isOriginLeft ? offset.left : offset.right;
var firstX = this.options.isOriginLeft ? offset.left : offset.right;
var lastX = firstX + stampSize.outerWidth;
var firstCol = Math.floor( firstX / this.columnWidth );
var lastCol = Math.floor( lastX / this.columnWidth );
// set colYs to bottom of the stamp
var stampMaxY = ( this.isOriginTop ? offset.top : offset.bottom ) +
var stampMaxY = ( this.options.isOriginTop ? offset.top : offset.bottom ) +
stampSize.outerHeight;
for ( var i = firstCol; i <= lastCol; i++ ) {
var colY = this.colYs[i];
Expand All @@ -152,6 +132,13 @@ function masonryDefinition( Outlayer, getSize ) {
}
};

Masonry.prototype._sizeContainerPostLayout = function() {
this.maxY = Math.max.apply( Math, this.colYs );
return {
height: this.maxY
};
};

return Masonry;
}

Expand Down
8 changes: 7 additions & 1 deletion notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!-- stamps -->

RTL
<!-- RTL -->

Tests

contributing.md

README

0 comments on commit 70a5dc1

Please sign in to comment.