' +
'' +
'' +
- '',
- $section = $(sectionHTML).appendTo('#qunit-fixture'),
- $scrollSpy = $section
+ ''
+ var $section = $(sectionHTML).appendTo('#qunit-fixture')
+ var $scrollSpy = $section
.show()
.find('#scrollspy-example')
- .bootstrapScrollspy({target: '#ss-target'})
+ .bootstrapScrollspy({ target: '#ss-target' })
+ $scrollSpy.on('scroll.bs.scrollspy', function () {
+ ok($section.hasClass('active'), 'Active class still on root node')
+ start()
+ })
$scrollSpy.scrollTop(350);
- ok($section.hasClass('active'), 'Active class still on root node')
+ })
+
+ asyncTest('middle navigation option correctly selected when large offset is used', function () {
+ expect(3);
+ var sectionHTML = '' +
+ '' +
+ '
' +
+ '' +
+ '' +
+ '' +
+ '
'
+ var $section = $(sectionHTML).appendTo('#qunit-fixture')
+ var $scrollSpy = $section
+ .show()
+ .filter('#content')
+ $scrollSpy.bootstrapScrollspy({ target: '#navigation', offset: $scrollSpy.position().top })
+
+ $scrollSpy.on('scroll.bs.scrollspy', function () {
+ ok(!$section.find('#one-link').parent().hasClass('active'), 'Active class removed from first section')
+ ok($section.find('#two-link').parent().hasClass('active'), 'Active class on middle section')
+ ok(!$section.find('#three-link').parent().hasClass('active'), 'Active class not on last section')
+ start()
+ })
+ $scrollSpy.scrollTop(550);
})
+
+ test('should add the active class to the correct element', function () {
+ var navbarHtml =
+ '