diff options
| author | fat <[email protected]> | 2013-07-25 23:53:34 -0700 |
|---|---|---|
| committer | fat <[email protected]> | 2013-07-25 23:53:34 -0700 |
| commit | 7ae8db8b7e11f0f4f735a711301750743e179bd5 (patch) | |
| tree | 900134e6eb15c973fe6f97b64e07a775cacb63df /javascript.html | |
| parent | f58827f24d6593bc36ff48b4c58a0fd954427326 (diff) | |
| download | bootstrap-7ae8db8b7e11f0f4f735a711301750743e179bd5.tar.xz bootstrap-7ae8db8b7e11f0f4f735a711301750743e179bd5.zip | |
update the affix docs a bit
Diffstat (limited to 'javascript.html')
| -rw-r--r-- | javascript.html | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/javascript.html b/javascript.html index 18d430f92..53bd00cd9 100644 --- a/javascript.html +++ b/javascript.html @@ -1729,24 +1729,26 @@ $('#myCarousel').on('slide.bs.carousel', function () { {% endhighlight %} <div class="bs-callout bs-callout-warning"> - <h4>Requires positioning</h4> - <p>You must manage the position of a pinned element and the behavior of its immediate parent. Position is controlled by <code>affix</code>, <code>affix-top</code>, and <code>affix-bottom</code>. Remember to check for a potentially collapsed parent when the affix kicks in as it's removing content from the normal flow of the page.</p> + <h4>Requires independent styling ;)</h4> + <p> + Affix toggles between three states/classes: <code>affix</code>, <code>affix-top</code>, and <code>affix-bottom</code>. You must provide the styles for these classes yourself (independent of this plugin). + The <code>affix-top</code> class should be in the regular flow of the document. The <code>affix</code> class should be fixed to the page. And <code>affix-bottom</code> should be positioned absolute. Note, <code>affix-bottom</code> is special in that the plugin will place the element with js relative to the <code>offset: { bottom: number }</code> option you've provided. + </p> </div> <h3>Via JavaScript</h3> <p>Call the affix plugin via JavaScript:</p> {% highlight js %} -$('#navbar').affix() + $('#myAffix').affix({ + offset: { + top: 100 + , bottom: function () { + return (this.bottom = $('.bs-footer').outerHeight(true)) + } + } + }) {% endhighlight %} - <h3>Methods</h3> - <h4>.affix('refresh')</h4> - <p>When using affix in conjunction with adding or removing of elements from the DOM, you'll want to call the refresh method:</p> -{% highlight js %} -$('[data-spy="affix"]').each(function () { - $(this).affix('refresh') -}); -{% endhighlight %} <h3>Options</h3> <p>Options can be passed via data attributes or JavaScript. For data attributes, append the option name to <code>data-</code>, as in <code>data-offset-top="200"</code>.</p> @@ -1765,7 +1767,7 @@ $('[data-spy="affix"]').each(function () { <td>offset</td> <td>number | function | object</td> <td>10</td> - <td>Pixels to offset from screen when calculating position of scroll. If a single number is provided, the offset will be applied in both top and left directions. To listen for a single direction, or multiple unique offsets, just provide an object <code>offset: { x: 10 }</code>. Use a function when you need to dynamically provide an offset (useful for some responsive designs).</td> + <td>Pixels to offset from screen when calculating position of scroll. If a single number is provided, the offset will be applied in both top and left directions. To listen for a single direction, or multiple unique offsets, just provide an object <code>offset: { top: 10 }</code>. Use a function when you need to dynamically provide an offset (useful for some responsive designs).</td> </tr> </tbody> </table> |
