|
1 | 1 | /**
|
2 |
| - * Isotope v1.2.110523 |
| 2 | + * Isotope v1.3.110523 |
3 | 3 | * An exquisite jQuery plugin for magical layouts
|
4 | 4 | * http://isotope.metafizzy.co
|
5 | 5 | *
|
|
636 | 636 |
|
637 | 637 |
|
638 | 638 | resize : function() {
|
639 |
| - this[ '_' + this.options.layoutMode + 'Resize' ](); |
| 639 | + if ( this[ '_' + this.options.layoutMode + 'ResizeChanged' ]() ) { |
| 640 | + this.reLayout(); |
| 641 | + } |
640 | 642 | },
|
641 | 643 |
|
642 | 644 |
|
|
757 | 759 |
|
758 | 760 | },
|
759 | 761 |
|
| 762 | + |
| 763 | + // ====================== LAYOUTS ====================== |
| 764 | + |
760 | 765 | // calculates number of rows or columns
|
761 | 766 | // requires columnWidth or rowHeight to be set on namespaced object
|
762 | 767 | // i.e. this.masonry.columnWidth = 200
|
763 |
| - _getSegments : function( namespace, isRows ) { |
764 |
| - var measure = isRows ? 'rowHeight' : 'columnWidth', |
| 768 | + _getSegments : function( isRows ) { |
| 769 | + var namespace = this.layoutMode, |
| 770 | + measure = isRows ? 'rowHeight' : 'columnWidth', |
765 | 771 | size = isRows ? 'height' : 'width',
|
766 | 772 | UCSize = isRows ? 'Height' : 'Width',
|
767 | 773 | segmentsName = isRows ? 'rows' : 'cols',
|
|
786 | 792 | this[ namespace ][ measure ] = segmentSize;
|
787 | 793 |
|
788 | 794 | },
|
| 795 | + |
| 796 | + _checkIfSegmentsChanged : function( isRows ) { |
| 797 | + var segmentsName = isRows ? 'rows' : 'cols', |
| 798 | + prevSegments = this[ this.layoutMode ][ segmentsName ]; |
| 799 | + // update cols/rows |
| 800 | + this._getSegments( isRows ); |
| 801 | + // return if updated cols/rows is not equal to previous |
| 802 | + var changed = ( this[ this.layoutMode ][ segmentsName ] !== prevSegments ); |
| 803 | + console.log( changed ); |
| 804 | + return changed; |
| 805 | + }, |
789 | 806 |
|
790 |
| - // ====================== LAYOUTS ====================== |
791 |
| - |
792 |
| - |
793 | 807 | // ====================== Masonry ======================
|
794 | 808 |
|
795 | 809 | _masonryPlaceBrick : function( $brick, setCount, setY ) {
|
|
858 | 872 | // layout-specific props
|
859 | 873 | this.masonry = {};
|
860 | 874 | // FIXME shouldn't have to call this again
|
861 |
| - this._getSegments('masonry'); |
| 875 | + this._getSegments(); |
862 | 876 | var i = this.masonry.cols;
|
863 | 877 | this.masonry.colYs = [];
|
864 | 878 | while (i--) {
|
865 | 879 | this.masonry.colYs.push( this.posTop );
|
866 | 880 | }
|
867 | 881 | },
|
868 | 882 |
|
869 |
| - _masonryResize : function() { |
870 |
| - var prevColCount = this.masonry.cols; |
871 |
| - // get updated colCount |
872 |
| - this._getSegments('masonry'); |
873 |
| - if ( this.masonry.cols !== prevColCount ) { |
874 |
| - // if column count has changed, do a new column cound |
875 |
| - this.reLayout(); |
876 |
| - } |
| 883 | + _masonryResizeChanged : function() { |
| 884 | + return this._checkIfSegmentsChanged(); |
877 | 885 | },
|
878 | 886 |
|
879 | 887 | _masonryGetContainerSize : function() {
|
|
923 | 931 | return { height : this.fitRows.height };
|
924 | 932 | },
|
925 | 933 |
|
926 |
| - _fitRowsResize : function() { |
927 |
| - this.reLayout(); |
| 934 | + _fitRowsResizeChanged : function() { |
| 935 | + return true; |
928 | 936 | },
|
929 | 937 |
|
930 | 938 |
|
931 | 939 | // ====================== cellsByRow ======================
|
932 | 940 |
|
933 | 941 | _cellsByRowReset : function() {
|
934 | 942 | this.cellsByRow = {};
|
935 |
| - this._getSegments('cellsByRow'); |
| 943 | + this._getSegments(); |
936 | 944 | this.cellsByRow.rowHeight = this.options.cellsByRow.rowHeight || this.$allAtoms.outerHeight(true);
|
937 | 945 | },
|
938 | 946 |
|
|
954 | 962 | return { height : Math.ceil( this.cellsByRow.atomsLen / this.cellsByRow.cols ) * this.cellsByRow.rowHeight + this.posTop };
|
955 | 963 | },
|
956 | 964 |
|
957 |
| - _cellsByRowResize : function() { |
958 |
| - var prevCols = this.cellsByRow.cols; |
959 |
| - this._getSegments('cellsByRow'); |
960 |
| - |
961 |
| - // if column count has changed, do a new column cound |
962 |
| - if ( this.cellsByRow.cols !== prevCols ) { |
963 |
| - this.reLayout(); |
964 |
| - } |
| 965 | + _cellsByRowResizeChanged : function() { |
| 966 | + return this._getIfSegmentsChanged(); |
965 | 967 | },
|
966 | 968 |
|
967 | 969 |
|
|
987 | 989 | return { height : this.straightDown.y + this.posTop };
|
988 | 990 | },
|
989 | 991 |
|
990 |
| - _straightDownResize : function() { |
991 |
| - this.reLayout(); |
| 992 | + _straightDownResizeChanged : function() { |
| 993 | + return true; |
992 | 994 | },
|
993 | 995 |
|
994 | 996 |
|
|
1057 | 1059 | // layout-specific props
|
1058 | 1060 | this.masonryHorizontal = {};
|
1059 | 1061 | // FIXME shouldn't have to call this again
|
1060 |
| - this._getSegments( 'masonryHorizontal', true ); |
| 1062 | + this._getSegments( true ); |
1061 | 1063 | var i = this.masonryHorizontal.rows;
|
1062 | 1064 | this.masonryHorizontal.rowXs = [];
|
1063 | 1065 | while (i--) {
|
1064 | 1066 | this.masonryHorizontal.rowXs.push( this.posLeft );
|
1065 | 1067 | }
|
1066 | 1068 | },
|
1067 | 1069 |
|
1068 |
| - _masonryHorizontalResize : function() { |
1069 |
| - var prevRows = this.masonryHorizontal.rows; |
1070 |
| - // get updated colCount |
1071 |
| - this._getSegments( 'masonryHorizontal', true ); |
1072 |
| - if ( this.masonryHorizontal.rows !== prevRows ) { |
1073 |
| - // if column count has changed, do a new column cound |
1074 |
| - this.reLayout(); |
1075 |
| - } |
| 1070 | + _masonryHorizontalResizeChanged : function() { |
| 1071 | + return this._getIfSegmentsChanged(); |
1076 | 1072 | },
|
1077 | 1073 |
|
1078 | 1074 | _masonryHorizontalGetContainerSize : function() {
|
|
1121 | 1117 | return { width : this.fitColumns.width };
|
1122 | 1118 | },
|
1123 | 1119 |
|
1124 |
| - _fitColumnsResize : function() { |
1125 |
| - this.reLayout(); |
| 1120 | + _fitColumnsResizeChanged : function() { |
| 1121 | + return true; |
1126 | 1122 | },
|
1127 | 1123 |
|
1128 | 1124 |
|
|
1131 | 1127 |
|
1132 | 1128 | _cellsByColumnReset : function() {
|
1133 | 1129 | this.cellsByColumn = {};
|
1134 |
| - this._getSegments( 'cellsByColumn', true ); |
| 1130 | + this._getSegments( true ); |
1135 | 1131 | this.cellsByColumn.columnWidth = this.options.cellsByColumn.columnWidth || this.$allAtoms.outerHeight(true);
|
1136 | 1132 | },
|
1137 | 1133 |
|
|
1153 | 1149 | return { width : Math.ceil( this.cellsByColumn.atomsLen / this.cellsByColumn.rows ) * this.cellsByColumn.columnWidth + this.posLeft };
|
1154 | 1150 | },
|
1155 | 1151 |
|
1156 |
| - _cellsByColumnResize : function() { |
1157 |
| - var prevRows = this.cellsByColumn.rows; |
1158 |
| - this._getSegments( 'cellsByColumn', true ); |
1159 |
| - |
1160 |
| - // if column count has changed, do a new column cound |
1161 |
| - if ( this.cellsByColumn.rows !== prevRows ) { |
1162 |
| - this.reLayout(); |
1163 |
| - } |
| 1152 | + _cellsByColumnResizeChanged : function() { |
| 1153 | + return this._getIfSegmentsChanged(); |
1164 | 1154 | },
|
1165 | 1155 |
|
1166 | 1156 | // ====================== straightAcross ======================
|
|
1185 | 1175 | return { width : this.straightAcross.x + this.posLeft };
|
1186 | 1176 | },
|
1187 | 1177 |
|
1188 |
| - _straightAcrossResize : function() { |
1189 |
| - this.reLayout(); |
| 1178 | + _straightAcrossResizeChanged : function() { |
| 1179 | + return true; |
1190 | 1180 | }
|
1191 | 1181 |
|
1192 | 1182 | };
|
|
0 commit comments