enmi12/glossaire/_posts/docs/2010-12-05-layout-modes.mdown
changeset 0 d970ebf37754
equal deleted inserted replaced
-1:000000000000 0:d970ebf37754
       
     1 ---
       
     2 
       
     3 title: Layout modes
       
     4 category: docs
       
     5 layout: default
       
     6 body_class: option-def
       
     7 toc:
       
     8   - { title: Horizontal layouts, anchor: horizontal_layouts }
       
     9   - { title: cellsByColumn, anchor: cellsbycolumn }
       
    10   - { title: cellsByRow, anchor: cellsbyrow }
       
    11   - { title: fitColumns, anchor: fitcolumns }
       
    12   - { title: fitRows, anchor: fitrows }
       
    13   - { title: masonry, anchor: masonry }
       
    14   - { title: masonryHorizontal, anchor: masonryhorizontal }
       
    15   - { title: straightAcross, anchor: straightacross }
       
    16   - { title: straightDown, anchor: straightdown }
       
    17   - { title: Modified layout modes, anchor: modified_layout_modes }
       
    18 
       
    19 ---
       
    20 
       
    21 Isotope has a versatile layout engine that can accommodate multiple layout modes. You can set and change the layout mode via the `layoutMode` option.
       
    22 
       
    23 [**See Demo: Layout modes**](../demos/layout-modes.html)
       
    24 
       
    25 ### Example
       
    26 
       
    27 {% highlight javascript %}
       
    28 
       
    29 $('#container').isotope({ layoutMode : 'fitRows' });
       
    30 
       
    31 {% endhighlight %}
       
    32 
       
    33 Several layout modes are built into Isotope.
       
    34 
       
    35 ### Horizontal layouts
       
    36 
       
    37 Horizontal layout modes (masonryHorizontal, fitColumns, cellsByColumn, and straightAcross) need a container that has a height value. Be sure that your CSS has height set.
       
    38 
       
    39 {% highlight css %}
       
    40 
       
    41 #container {
       
    42   /* either of these will work for horizontal Isotope layouts */
       
    43   height: 80%;
       
    44   height: 480px;
       
    45 }
       
    46 
       
    47 {% endhighlight %}
       
    48 
       
    49 ## cellsByColumn
       
    50 
       
    51 A **horizontal** grid layout where items are centered inside each cell. The grid is defined by two options, `columnWidth` and `rowHeight`. The horizontal equivalent of cellsByRow.
       
    52 
       
    53 ### Options {#cellsByColumn-options}
       
    54 
       
    55 <dl class="clearfix">
       
    56   <dt><code>columnWidth</code></dt>
       
    57   <dd class="option-type">Integer</dd>
       
    58 </dl>
       
    59 <dl class="clearfix">
       
    60   <dt><code>rowHeight</code></dt>
       
    61   <dd class="option-type">Integer</dd>
       
    62 </dl>
       
    63 
       
    64 ### Example {#cellsByColumn-example}
       
    65 
       
    66 {% highlight javascript %}
       
    67 
       
    68 $('#container').isotope({
       
    69   layoutMode: 'cellsByColumn',
       
    70   cellsByRow: {
       
    71     columnWidth: 240,
       
    72     rowHeight: 360
       
    73   }
       
    74 });
       
    75 
       
    76 {% endhighlight %}
       
    77 
       
    78 
       
    79 ## cellsByRow
       
    80 
       
    81 A **vertical** grid layout where items are centered inside each cell. The grid is defined by two options, `columnWidth` and `rowHeight`.
       
    82 
       
    83 ### Options {#cellsByRow-options}
       
    84 
       
    85 <dl class="clearfix">
       
    86   <dt><code>columnWidth</code></dt>
       
    87   <dd class="option-type">Integer</dd>
       
    88 </dl>
       
    89 <dl class="clearfix">
       
    90   <dt><code>rowHeight</code></dt>
       
    91   <dd class="option-type">Integer</dd>
       
    92 </dl>
       
    93 
       
    94 ### Example {#cellsByRow-example}
       
    95 
       
    96 {% highlight javascript %}
       
    97 
       
    98 $('#container').isotope({
       
    99   layoutMode: 'cellsByRow',
       
   100   cellsByRow: {
       
   101     columnWidth: 240,
       
   102     rowHeight: 360
       
   103   }
       
   104 });
       
   105 
       
   106 {% endhighlight %}
       
   107 
       
   108 ## fitColumns
       
   109 
       
   110 Item elements are arranged into columns. Columns progress **horizontally** from left to right. Items within those columns are arranged top-to-bottom. The horizontal equivalent of fitRows. 
       
   111 
       
   112 ## fitRows
       
   113 
       
   114 Item elements are arranged into rows. Rows progress **vertically** top to bottom. Similar to what you would expect from a layout that uses `float: left`.
       
   115 
       
   116 ## masonry
       
   117 
       
   118 Masonry is the default layout mode for Isotope. Item elements are arranged intelligently within a **vertical** grid. For each item element, the script calculates the next best fit for the item within the grid.
       
   119 
       
   120 ### Options {#masonry-options}
       
   121 
       
   122 <dl class="clearfix">
       
   123   <dt><code>columnWidth</code></dt>
       
   124   <dd class="option-type">Integer</dd>
       
   125 </dl>
       
   126 
       
   127 The width of one column in the grid. If no value is set for `columnWidth`, default is the width of the first item element.
       
   128 
       
   129 ### Example {#masonry-example}
       
   130 
       
   131 {% highlight javascript %}
       
   132 
       
   133 $('#container').isotope({
       
   134   masonry: {
       
   135     columnWidth: 240
       
   136   }
       
   137 });
       
   138 
       
   139 {% endhighlight %}
       
   140 
       
   141 
       
   142 ## masonryHorizontal
       
   143 
       
   144 The **horizontal** equivalent of masonry layout. Instead of progressing top-to-bottom, masonryHorizontal layout will progress left-to-right. Item elements are arranged intelligently within a grid. For each item element, the script calculates the next best fit for the item within the grid.
       
   145 
       
   146 ### Options {#masonryHorizontal-options}
       
   147 
       
   148 <dl class="clearfix">
       
   149   <dt><code>rowHeight</code></dt>
       
   150   <dd class="option-type">Integer</dd>
       
   151 </dl>
       
   152 
       
   153 The width of one column in the grid. If no value is set for `rowHeight`, default is the height of the first item element.
       
   154 
       
   155 ### Example {#masonryHorizontal-example}
       
   156 
       
   157 {% highlight javascript %}
       
   158 
       
   159 $('#container').isotope({
       
   160   masonryHorizontal: {
       
   161     rowHeight: 360
       
   162   }
       
   163 });
       
   164 
       
   165 {% endhighlight %}
       
   166 
       
   167 ## straightAcross
       
   168 
       
   169 Item elements are arranged **horizontally** left to right. Useful for simple lists.
       
   170 
       
   171 ## straightDown
       
   172 
       
   173 Item elements are arranged **vertically** top to bottom. Useful for simple lists.
       
   174 
       
   175 ## Modified layout modes
       
   176 
       
   177 [Isotope's methods can be extended and overwritten](extending-isotope.html) to shim-in additional functionality. See these modified layout modes:
       
   178 
       
   179 + [**Centered masonry**](../custom-layout-modes/centered-masonry.html)
       
   180 + [**Masonry corner stamp**](../custom-layout-modes/masonry-corner-stamp.html)
       
   181 + [**Masonry gutters**](../custom-layout-modes/masonry-gutters.html)
       
   182 
       
   183 To use these mods, copy the revised methods found in the demos' page source. They look like:
       
   184 
       
   185 {% highlight javascript %}
       
   186 
       
   187 $.Isotope.prototype._masonryReset = function() {
       
   188   // modified code..
       
   189 };
       
   190 
       
   191 {% endhighlight %}