]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Fixes affix-top class not applying
authorNick O'Donoghue <nick.od@me.com>
Sun, 16 Nov 2014 21:01:32 +0000 (21:01 +0000)
committerChris Rebert <code@rebertia.com>
Tue, 18 Nov 2014 02:17:42 +0000 (18:17 -0800)
Use scrollTop instead of colliderTop which uses the elements
offset().top, as the offset top does not account for padding.

This issue can be replicated by using a navbar-fixed-top and applying
relevant padding to the body. (A navbar-static-top with no padding on
the body does not encounter this issue)

Fixes #15078
Closes #15154 by merging it

js/affix.js

index deea29485fd562abb167efdfdae2e3d309247cff..04f389e2c5108755b53198b48d15545092bcb1f6 100644 (file)
@@ -53,7 +53,7 @@
     var colliderTop    = initializing ? scrollTop : position.top
     var colliderHeight = initializing ? targetHeight : height
 
-    if (offsetTop != null && colliderTop <= offsetTop) return 'top'
+    if (offsetTop != null && scrollTop <= offsetTop) return 'top'
     if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'
 
     return false