]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
update the affix docs a bit
authorfat <jacobthornton@gmail.com>
Fri, 26 Jul 2013 06:53:34 +0000 (23:53 -0700)
committerfat <jacobthornton@gmail.com>
Fri, 26 Jul 2013 06:53:34 +0000 (23:53 -0700)
javascript.html

index 18d430f9233c345a45fc4cf561e4beed2a39da6b..53bd00cd94df23fe2335e4208c5892b117697d0e 100644 (file)
@@ -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>