Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bootstrap
Commits
015e63f6
Commit
015e63f6
authored
Mar 01, 2015
by
Chris Rebert
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15593 from neoeno/handle_multiple_zero_offset_scrollspy_elements
Handle multiple zero-offset Scrollspy elements.
parents
08e0f239
a1aa0f8a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
js/scrollspy.js
js/scrollspy.js
+1
-1
js/tests/unit/scrollspy.js
js/tests/unit/scrollspy.js
+38
-0
No files found.
js/scrollspy.js
View file @
015e63f6
...
@@ -96,7 +96,7 @@
...
@@ -96,7 +96,7 @@
for
(
i
=
offsets
.
length
;
i
--
;)
{
for
(
i
=
offsets
.
length
;
i
--
;)
{
activeTarget
!=
targets
[
i
]
activeTarget
!=
targets
[
i
]
&&
scrollTop
>=
offsets
[
i
]
&&
scrollTop
>=
offsets
[
i
]
&&
(
!
offsets
[
i
+
1
]
||
scrollTop
<=
offsets
[
i
+
1
])
&&
(
offsets
[
i
+
1
]
===
undefined
||
scrollTop
<=
offsets
[
i
+
1
])
&&
this
.
activate
(
targets
[
i
])
&&
this
.
activate
(
targets
[
i
])
}
}
}
}
...
...
js/tests/unit/scrollspy.js
View file @
015e63f6
...
@@ -142,6 +142,44 @@ $(function () {
...
@@ -142,6 +142,44 @@ $(function () {
.
then
(
function
()
{
return
testElementIsActiveAfterScroll
(
'
#li-2
'
,
'
#div-2
'
)
})
.
then
(
function
()
{
return
testElementIsActiveAfterScroll
(
'
#li-2
'
,
'
#div-2
'
)
})
})
})
QUnit
.
test
(
'
should add the active class correctly when there are nested elements at 0 scroll offset
'
,
function
(
assert
)
{
var
times
=
0
var
done
=
assert
.
async
()
var
navbarHtml
=
'
<nav id="navigation" class="navbar">
'
+
'
<ul class="nav">
'
+
'
<li id="li-1"><a href="#div-1">div 1</a>
'
+
'
<ul>
'
+
'
<li id="li-2"><a href="#div-2">div 2</a></li>
'
+
'
</ul>
'
+
'
</li>
'
+
'
</ul>
'
+
'
</nav>
'
var
contentHtml
=
'
<div class="content" style="position: absolute; top: 0px; overflow: auto; height: 50px">
'
+
'
<div id="div-1" style="padding: 0; margin: 0">
'
+
'
<div id="div-2" style="height: 200px; padding: 0; margin: 0">div 2</div>
'
+
'
</div>
'
+
'
</div>
'
$
(
navbarHtml
).
appendTo
(
'
#qunit-fixture
'
)
var
$content
=
$
(
contentHtml
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapScrollspy
({
offset
:
0
,
target
:
'
#navigation
'
})
!
function
testActiveElements
()
{
if
(
++
times
>
3
)
return
done
()
$content
.
one
(
'
scroll
'
,
function
()
{
assert
.
ok
(
$
(
'
#li-1
'
).
hasClass
(
'
active
'
),
'
nav item for outer element has "active" class
'
)
assert
.
ok
(
$
(
'
#li-2
'
).
hasClass
(
'
active
'
),
'
nav item for inner element has "active" class
'
)
testActiveElements
()
})
$content
.
scrollTop
(
$content
.
scrollTop
()
+
10
)
}()
})
QUnit
.
test
(
'
should clear selection if above the first section
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should clear selection if above the first section
'
,
function
(
assert
)
{
var
done
=
assert
.
async
()
var
done
=
assert
.
async
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment