enmi12/glossaire/_posts/docs/2010-12-05-layout-modes.mdown
author ymh <ymh.work@gmail.com>
Mon, 14 Oct 2019 17:39:30 +0200
changeset 7 cf61fcea0001
parent 0 d970ebf37754
permissions -rwxr-xr-x
resynchronize code repo with production
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
---
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
title: Layout modes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
category: docs
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
layout: default
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
body_class: option-def
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
toc:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
  - { title: Horizontal layouts, anchor: horizontal_layouts }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
  - { title: cellsByColumn, anchor: cellsbycolumn }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
  - { title: cellsByRow, anchor: cellsbyrow }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
  - { title: fitColumns, anchor: fitcolumns }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
  - { title: fitRows, anchor: fitrows }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
  - { title: masonry, anchor: masonry }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
  - { title: masonryHorizontal, anchor: masonryhorizontal }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
  - { title: straightAcross, anchor: straightacross }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
  - { title: straightDown, anchor: straightdown }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
  - { title: Modified layout modes, anchor: modified_layout_modes }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
---
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
[**See Demo: Layout modes**](../demos/layout-modes.html)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
### Example
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
{% highlight javascript %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
$('#container').isotope({ layoutMode : 'fitRows' });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
{% endhighlight %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
Several layout modes are built into Isotope.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
### Horizontal layouts
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
{% highlight css %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
#container {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
  /* either of these will work for horizontal Isotope layouts */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
  height: 80%;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
  height: 480px;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
{% endhighlight %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
## cellsByColumn
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
### Options {#cellsByColumn-options}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
<dl class="clearfix">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
  <dt><code>columnWidth</code></dt>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
  <dd class="option-type">Integer</dd>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
</dl>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
<dl class="clearfix">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
  <dt><code>rowHeight</code></dt>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
  <dd class="option-type">Integer</dd>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
</dl>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
### Example {#cellsByColumn-example}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
{% highlight javascript %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
$('#container').isotope({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
  layoutMode: 'cellsByColumn',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
  cellsByRow: {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
    columnWidth: 240,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
    rowHeight: 360
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
{% endhighlight %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
## cellsByRow
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
A **vertical** grid layout where items are centered inside each cell. The grid is defined by two options, `columnWidth` and `rowHeight`.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
### Options {#cellsByRow-options}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
<dl class="clearfix">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
  <dt><code>columnWidth</code></dt>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
  <dd class="option-type">Integer</dd>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
</dl>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
<dl class="clearfix">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
  <dt><code>rowHeight</code></dt>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
  <dd class="option-type">Integer</dd>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
</dl>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
### Example {#cellsByRow-example}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
{% highlight javascript %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
$('#container').isotope({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
  layoutMode: 'cellsByRow',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
  cellsByRow: {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
    columnWidth: 240,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
    rowHeight: 360
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
{% endhighlight %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
## fitColumns
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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. 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
## fitRows
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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`.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
## masonry
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
### Options {#masonry-options}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
<dl class="clearfix">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
  <dt><code>columnWidth</code></dt>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
  <dd class="option-type">Integer</dd>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
</dl>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
### Example {#masonry-example}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
{% highlight javascript %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
$('#container').isotope({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
  masonry: {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
    columnWidth: 240
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
{% endhighlight %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
## masonryHorizontal
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
### Options {#masonryHorizontal-options}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
<dl class="clearfix">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
  <dt><code>rowHeight</code></dt>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
  <dd class="option-type">Integer</dd>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
</dl>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   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.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
### Example {#masonryHorizontal-example}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
{% highlight javascript %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
$('#container').isotope({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
  masonryHorizontal: {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
    rowHeight: 360
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
{% endhighlight %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
## straightAcross
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
Item elements are arranged **horizontally** left to right. Useful for simple lists.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
## straightDown
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
Item elements are arranged **vertically** top to bottom. Useful for simple lists.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
## Modified layout modes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
[Isotope's methods can be extended and overwritten](extending-isotope.html) to shim-in additional functionality. See these modified layout modes:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
+ [**Centered masonry**](../custom-layout-modes/centered-masonry.html)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
+ [**Masonry corner stamp**](../custom-layout-modes/masonry-corner-stamp.html)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
+ [**Masonry gutters**](../custom-layout-modes/masonry-gutters.html)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
To use these mods, copy the revised methods found in the demos' page source. They look like:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
{% highlight javascript %}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
$.Isotope.prototype._masonryReset = function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
  // modified code..
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
{% endhighlight %}