diff --git a/javascript.html b/javascript.html index 18d430f923..53bd00cd94 100644 --- a/javascript.html +++ b/javascript.html @@ -1729,24 +1729,26 @@ $('#myCarousel').on('slide.bs.carousel', function () { {% endhighlight %}
-

Requires positioning

-

You must manage the position of a pinned element and the behavior of its immediate parent. Position is controlled by affix, affix-top, and affix-bottom. 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.

+

Requires independent styling ;)

+

+ Affix toggles between three states/classes: affix, affix-top, and affix-bottom. You must provide the styles for these classes yourself (independent of this plugin). + The affix-top class should be in the regular flow of the document. The affix class should be fixed to the page. And affix-bottom should be positioned absolute. Note, affix-bottom is special in that the plugin will place the element with js relative to the offset: { bottom: number } option you've provided. +

Via JavaScript

Call the affix plugin via JavaScript:

{% highlight js %} -$('#navbar').affix() + $('#myAffix').affix({ + offset: { + top: 100 + , bottom: function () { + return (this.bottom = $('.bs-footer').outerHeight(true)) + } + } + }) {% endhighlight %} -

Methods

-

.affix('refresh')

-

When using affix in conjunction with adding or removing of elements from the DOM, you'll want to call the refresh method:

-{% highlight js %} -$('[data-spy="affix"]').each(function () { - $(this).affix('refresh') -}); -{% endhighlight %}

Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-offset-top="200".

@@ -1765,7 +1767,7 @@ $('[data-spy="affix"]').each(function () { offset number | function | object 10 - 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 offset: { x: 10 }. Use a function when you need to dynamically provide an offset (useful for some responsive designs). + 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 offset: { top: 10 }. Use a function when you need to dynamically provide an offset (useful for some responsive designs).