Browse Source

add layout-mode.js

pull/563/head
David DeSandro 12 years ago
parent
commit
2191885744
  1. 1
      examples/sorting.html
  2. 7
      isotope.js
  3. 51
      layout-mode.js
  4. 14
      layout-modes/fit-rows.js
  5. 3
      notes.md

1
examples/sorting.html

@ -144,6 +144,7 @@
<script src="../item.js"></script>
<script src="../isotope.js"></script>
<script src="../layout-mode.js"></script>
<script src="../layout-modes/fit-rows.js"></script>
<script>

7
isotope.js

@ -35,7 +35,7 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item ) {
this.modes = {};
// create from registered layout modes
for ( var name in Isotope.layoutModes ) {
this._createLayoutMode( name );
this._initLayoutMode( name );
}
// keep of track of sortBys
this.sortHistory = [ 'original-order' ];
@ -61,10 +61,9 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item ) {
// -------------------------- layout -------------------------- //
Isotope.prototype._createLayoutMode = function( name ) {
Isotope.prototype._initLayoutMode = function( name ) {
var LayoutMode = Isotope.layoutModes[ name ];
var options = this.options[ name ];
this.modes[ name ] = new LayoutMode( this, options );
this.modes[ name ] = new LayoutMode( this );
};
Isotope.prototype._mode = function() {

51
layout-mode.js

@ -0,0 +1,51 @@
( function( window ) {
'use strict';
// -------------------------- -------------------------- //
var Isotope = window.Isotope;
var Outlayer = window.Outlayer;
function LayoutMode( isotope ) {
this.isotope = isotope;
// link options to isotope.options
this.options = isotope && isotope.options[ this.namespace ];
}
// default methods just defer to Isotope
LayoutMode.prototype._resetLayout = function() {
Outlayer.prototype._resetLayout.apply( this.isotope, arguments );
};
LayoutMode.prototype._getItemLayoutPosition = function() {
return Outlayer.prototype._getItemLayoutPosition.apply( this.isotope, arguments );
};
LayoutMode.prototype._manageStamp = function() {
Outlayer.prototype._manageStamp.apply( this.isotope, arguments );
};
LayoutMode.prototype._getContainerSize = function() {
return Outlayer.prototype._getContainerSize.apply( this.isotope, arguments );
};
// -------------------------- create -------------------------- //
LayoutMode.create = function( namespace, options ) {
// subclass LayoutMode
function Mode() {
LayoutMode.apply( this, arguments );
}
Mode.prototype = new LayoutMode();
Mode.prototype.namespace = namespace;
// set default options
Isotope.prototype.options[ namespace ] = options || {};
// register in Isotope
Isotope.layoutModes[ namespace ] = Mode;
return Mode;
};
Isotope.LayoutMode = LayoutMode;
})( window );

14
layout-modes/fit-rows.js

@ -4,11 +4,9 @@
var Isotope = window.Isotope;
var Outlayer = window.Outlayer;
function FitRows( isotope, options ) {
this.isotope = isotope;
this.options = options;
}
var FitRows = Isotope.LayoutMode.create( 'fitRows', {
foo: 'bar'
});
FitRows.prototype._resetLayout = function() {
Outlayer.prototype._resetLayout.apply( this.isotope, arguments );
@ -37,14 +35,8 @@ FitRows.prototype._getItemLayoutPosition = function( item ) {
return position;
};
FitRows.prototype._manageStamp = function() {
Outlayer.prototype._manageStamp.apply( this.isotope, arguments );
};
FitRows.prototype._getContainerSize = function() {
return { height: this.maxY };
};
Isotope.layoutModes.fitRows = FitRows;
})( window );

3
notes.md

@ -8,3 +8,6 @@ filter
filter on init doesn't do transition
sortAscending
sortAscending for object

Loading…
Cancel
Save