aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorNick O'Donoghue <[email protected]>2014-11-17 00:42:55 +0000
committerChris Rebert <[email protected]>2014-11-17 18:17:40 -0800
commitda79ab94889dd72c83245c376e278a4c378f84b4 (patch)
treee78ff60d8424427150d141703aae209c4731ece0 /js
parent423825f50670174033e85a3ebe59743e05e4e415 (diff)
downloadbootstrap-da79ab94889dd72c83245c376e278a4c378f84b4.tar.xz
bootstrap-da79ab94889dd72c83245c376e278a4c378f84b4.zip
add unit test for affix-top for padding issue
Diffstat (limited to 'js')
-rw-r--r--js/tests/unit/affix.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/js/tests/unit/affix.js b/js/tests/unit/affix.js
index ef6ef74b9..2e82a7dbf 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 = '<div id="padding-offset" style="padding-top: 20px;">'
+ + '<div id="affixTopTarget">'
+ + '<p>Testing affix-top class is added</p>'
+ + '</div>'
+ + '<div style="height: 1000px; display: block;"/>'
+ + '</div>'
+ $(templateHTML).appendTo(document.body)
+
+ $('#affixTopTarget')
+ .bootstrapAffix({
+ offset: { top: 120, bottom: 0 }
+ })
+ .on('affixed-top.bs.affix', function () {
+ ok($('#affixTopTarget').hasClass('affix-top'), 'affix-top class applied')
+ start()
+ })
+
+ setTimeout(function () {
+ window.scrollTo(0, document.body.scrollHeight)
+
+ setTimeout(function () {
+ window.scroll(0, 119)
+ }, 250)
+ }, 250)
+ })
})