Browse Source

Clear float method working in widget form

pull/14/head
David DeSandro 14 years ago
parent
commit
fc9f170c3d
  1. 45
      src/jquery.molequul-widget.js

45
src/jquery.molequul-widget.js

@ -172,21 +172,8 @@
this._sort(); this._sort();
} }
// console.log( '_' + this.options.layoutMode + 'ResetLayoutProps' )
// this[ '_' + this.options.layoutMode + 'ResetLayoutProps' ]();
// console.log( $.data( this.$elem, 'molequul') );
// setTimeout( function(){
// this.layout( this.atoms.$filtered, callback );
this.reLayout( callback ); this.reLayout( callback );
// instance.$elem.molequul( 'layout', instance.atoms.$filtered, callback );
// }, 0)
// console.log( this )
// init code
}, },
option: function( key, value ){ option: function( key, value ){
@ -442,26 +429,27 @@
// ====================== ClearFloat ====================== // ====================== ClearFloat ======================
clearFloat : function( props ) { _clearFloat : function( $elems ) {
return this.each( function() { var instance = this;
return $elems.each( function() {
var $this = $(this), var $this = $(this),
atomW = $this.outerWidth(true), atomW = $this.outerWidth(true),
atomH = $this.outerHeight(true), atomH = $this.outerHeight(true),
x, y; x, y;
if ( props.clearFloat.x !== 0 && atomW + props.clearFloat.x > props.width ) { if ( instance.clearFloat.x !== 0 && atomW + instance.clearFloat.x > instance.width ) {
// if this element cannot fit in the current row // if this element cannot fit in the current row
props.clearFloat.x = 0; instance.clearFloat.x = 0;
props.clearFloat.y = props.clearFloat.height; instance.clearFloat.y = instance.clearFloat.height;
} }
// position the atom // position the atom
x = props.clearFloat.x + props.posLeft; x = instance.clearFloat.x + instance.posLeft;
y = props.clearFloat.y + props.posTop; y = instance.clearFloat.y + instance.posTop;
$this.molequul( 'pushPosition', x, y, props ); instance._pushPosition( $this, x, y );
props.clearFloat.height = Math.max( props.clearFloat.y + atomH, props.clearFloat.height ); instance.clearFloat.height = Math.max( instance.clearFloat.y + atomH, instance.clearFloat.height );
props.clearFloat.x += atomW; instance.clearFloat.x += atomW;
}); });
}, },
@ -471,8 +459,8 @@
return this; return this;
}, },
clearFloatResetLayoutProps : function( props ) { _clearFloatResetLayoutProps : function() {
props.clearFloat = { this.clearFloat = {
x : 0, x : 0,
y : 0, y : 0,
height : 0 height : 0
@ -498,11 +486,11 @@
layout : function( $elems, callback ) { layout : function( $elems, callback ) {
var layoutMode = this.options.layoutMode, var layoutMode = this.options.layoutMode,
layoutMethod = layoutMode; layoutMethod = '_' + layoutMode;
// layout logic // layout logic
if ( layoutMethod === 'masonry' ) { if ( layoutMethod === '_masonry' ) {
layoutMethod = this.options.masonrySingleMode ? '_masonrySingleColumn' : '_masonryMultiColumn'; layoutMethod += this.options.masonrySingleMode ? 'SingleColumn' : 'MultiColumn';
} }
this[ layoutMethod ]( $elems ); this[ layoutMethod ]( $elems );
@ -552,7 +540,6 @@
reLayout : function( callback ) { reLayout : function( callback ) {
console.log('layout again')
this this
[ '_' + this.options.layoutMode + 'ResetLayoutProps' ]() [ '_' + this.options.layoutMode + 'ResetLayoutProps' ]()
.layout( this.atoms.$filtered, callback ) .layout( this.atoms.$filtered, callback )

Loading…
Cancel
Save