diff --git a/js/affix.js b/js/affix.js index deea29485f..04f389e2c5 100644 --- a/js/affix.js +++ b/js/affix.js @@ -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 diff --git a/js/tests/unit/affix.js b/js/tests/unit/affix.js index ef6ef74b91..2e82a7dbfb 100644 --- a/js/tests/unit/affix.js +++ b/js/tests/unit/affix.js @@ -68,4 +68,33 @@ $(function () { }, 16) // for testing in a browser }, 0) }) + + test('should affix-top when scrolling up to offset when parent has padding', function () { + stop() + + var templateHTML = '
Testing affix-top class is added
' + + '