/components/jquery-masonry/_posts/docs/2011-05-02-options.mdown
https://bitbucket.org/ceoaliongroo/torredelprior · Unknown · 157 lines · 110 code · 47 blank · 0 comment · 0 complexity · 9cf25161d6e0de586fde919b8dfb0cf1 MD5 · raw file
- ---
- title: Options
- category: docs
- layout: default
- body_class: options
- toc :
- - { title: animationOptions, anchor: animationoptions }
- - { title: columnWidth, anchor: columnwidth }
- - { title: containerStyle, anchor: containerstyle }
- - { title: gutterWidth, anchor: gutterwidth }
- - { title: isAnimated, anchor: isanimated }
- - { title: isFitWidth, anchor: isfitwidth }
- - { title: isResizable, anchor: isresizable }
- - { title: isRTL, anchor: isrtl }
- - { title: itemSelector, anchor: itemselector }
- ---
- Options are set with an object as second argument to the `.masonry()` method. All options are optional, and do not need to be set, but [`itemSelector`](#itemselector) and [`columnWidth`](#columnwidth) are recommended.
- {% highlight javascript %}
- $('#container').masonry({
- itemSelector: '.box',
- columnWidth: 240,
- animationOptions: {
- duration: 400
- }
- });
- {% endhighlight %}
- <dl class="header clearfix">
- <dt><code>option</code></dt>
- <dd class="option-type">Type</dd>
- <dd class="default">Default</dd>
- </dl>
- ## animationOptions
- <dl class="clearfix">
- <dt><code>animationOptions</code></dt>
- <dd class="option-type">Object</dd>
- <dd class="default"><code>{ queue: <span class="kc">false</span>, duration: <span class="mi">500</span> }</code></dd>
- </dl>
- Options used for jQuery animation. See the [jQuery API for animate options](http://api.jquery.com/animate/#animate-properties-options) for details. More details in [Animating](animating.html).
- ## columnWidth
- <dl class="clearfix">
- <dt><code>columnWidth</code></dt>
- <dd class="option-type">Integer</dd>
- </dl>
- Width in pixels of 1 column of your grid. If no columnWidth is specified, Masonry uses the width of the first item element.
- **Recommended** if your layout has item elements that have multiple-column widths.
- To set a dynamic column width, you can pass in a function that returns the value column width. The function provides an argument for the width of the container. Use this technique for fluid or responsive layouts.
- {% highlight javascript %}
- $('#container').masonry({
- // set columnWidth a fraction of the container width
- columnWidth: function( containerWidth ) {
- return containerWidth / 5;
- }
- });
- {% endhighlight %}
- [See Demo: Fluid](../demos/fluid.html).
- ## containerStyle
- <dl class="clearfix">
- <dt><code>containerStyle</code></dt>
- <dd class="option-type">Object</dd>
- <dd class="default"><code>{ position: <span class="s1">'relative'</span> }</code></dd>
- </dl>
- CSS properties applied to the container. Masonry uses relative/absolute positioning to position item elements.
- ## gutterWidth
- <dl class="clearfix">
- <dt><code>gutterWidth</code></dt>
- <dd class="option-type">Integer</dd>
- <dd class="default"><code><span class="mi">0</span></code></dd>
- </dl>
- Adds additional spacing between columns.
- [See Demo: Gutters](../demos/gutters.html).
- ## isAnimated
- <dl class="clearfix">
- <dt><code>isAnimated</code></dt>
- <dd class="option-type">Boolean</dd>
- <dd class="default"><code><span class="kc">false</span></code></dd>
- </dl>
- Enables jQuery animation on layout changes. [See Docs: Animating](animating.html). More details in [Animating](animating.html).
- ## isFitWidth
- <dl class="clearfix">
- <dt><code>isFitWidth</code></dt>
- <dd class="option-type">Boolean</dd>
- <dd class="default"><code><span class="kc">false</span></code></dd>
- </dl>
- If enabled, Masonry will size the width of the container to the nearest column. When enabled, Masonry will measure the width of the container's parent element, not the width of the container. This option is ideal for centering Masonry layouts.
- [See Demo: Centered](../demos/centered.html).
- ## isResizable
- <dl class="clearfix">
- <dt><code>isResizable</code></dt>
- <dd class="option-type">Boolean</dd>
- <dd class="default"><code><span class="kc">true</span></code></dd>
- </dl>
- Triggers layout logic when browser window is resized.
- ## isRTL
- <dl class="clearfix">
- <dt><code>isRTL</code></dt>
- <dd class="option-type">Boolean</dd>
- <dd class="default"><code><span class="kc">false</span></code></dd>
- </dl>
- Enables right-to-left layout for languages like Hebrew and Arabic.
- [See Demo: Right-to-left](../demos/right-to-left.html).
- ## itemSelector
- <dl class="clearfix">
- <dt><code>itemSelector</code></dt>
- <dd class="option-type">String</dd>
- </dl>
- Filters item elements to selector. If not set, Masonry defaults to using the child elements of the container.
- **Recommended** to avoid Masonry using any other hidden elements in its layout logic.
- {% highlight javascript %}
- $('#container').masonry({ itemSelector: '.box' });
- {% endhighlight %}