Browse Source

js : use $.extend methods for masonry & clearFloat layouts

pull/14/head
David DeSandro 14 years ago
parent
commit
8f1c60f622
  1. 41
      src/jquery.ionize.js

41
src/jquery.ionize.js

@ -477,7 +477,9 @@
// ====================== Masonry ====================== // ====================== Masonry ======================
$.Ionizer.prototype._masonryPlaceBrick = function( $brick, setCount, setY ) { $.extend( $.Ionizer.prototype, {
_masonryPlaceBrick : function( $brick, setCount, setY ) {
// here, `this` refers to a child element or "brick" // here, `this` refers to a child element or "brick"
// get the minimum Y value from the columns // get the minimum Y value from the columns
var minimumY = Math.min.apply( Math, setY ), var minimumY = Math.min.apply( Math, setY ),
@ -503,10 +505,10 @@
this.masonry.colYs[ shortCol + i ] = setHeight; this.masonry.colYs[ shortCol + i ] = setHeight;
} }
}; },
$.Ionizer.prototype._masonryLayout = function( $elems ) { _masonryLayout : function( $elems ) {
var instance = this; var instance = this;
$elems.each(function(){ $elems.each(function(){
var $this = $(this), var $this = $(this),
@ -538,7 +540,7 @@
}; };
// reset // reset
$.Ionizer.prototype._masonryReset = function() { _masonryReset : function() {
// layout-specific props // layout-specific props
this.masonry = {}; this.masonry = {};
// FIXME shouldn't have to call this again // FIXME shouldn't have to call this again
@ -549,11 +551,11 @@
this.masonry.colYs.push( this.posTop ); this.masonry.colYs.push( this.posTop );
} }
return this; return this;
}; },
$.Ionizer.prototype._masonryResize = function() { _masonryResize : function() {
var prevColCount = this.masonry.cols; var prevColCount = this.masonry.cols;
// get updated colCount // get updated colCount
this._getSegments('masonry'); this._getSegments('masonry');
@ -563,17 +565,20 @@
} }
return this; return this;
}; },
$.Ionizer.prototype._masonryGetContainerSize = function() { _masonryGetContainerSize : function() {
var containerHeight = Math.max.apply( Math, this.masonry.colYs ) - this.posTop; var containerHeight = Math.max.apply( Math, this.masonry.colYs ) - this.posTop;
return { height: containerHeight }; return { height: containerHeight };
}; }
});
// ====================== clearFloat ====================== // ====================== clearFloat ======================
$.Ionizer.prototype._clearFloatLayout = function( $elems ) { $.extend( $.Ionizer.prototype, {
_clearFloatLayout : function( $elems ) {
var instance = this; var instance = this;
return $elems.each( function() { return $elems.each( function() {
var $this = $(this), var $this = $(this),
@ -596,25 +601,27 @@
instance.clearFloat.x += atomW; instance.clearFloat.x += atomW;
}); });
}; },
$.Ionizer.prototype._clearFloatReset = function() { _clearFloatReset : function() {
this.clearFloat = { this.clearFloat = {
x : 0, x : 0,
y : 0, y : 0,
height : 0 height : 0
}; };
return this; return this;
}; },
$.Ionizer.prototype._clearFloatGetContainerSize = function () { _clearFloatGetContainerSize : function () {
return { height : this.clearFloat.height }; return { height : this.clearFloat.height };
}; },
$.Ionizer.prototype._clearFloatResize = function() { _clearFloatResize : function() {
this.width = this.element.width(); this.width = this.element.width();
return this.reLayout() return this.reLayout()
}; }
});
// ====================== cellsByRow ====================== // ====================== cellsByRow ======================

Loading…
Cancel
Save