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
c77740bd
Commit
c77740bd
authored
Dec 24, 2013
by
fat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes #11720 - Add events trigger to affix
parent
073f8c04
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
6 deletions
+51
-6
dist/js/bootstrap.js
dist/js/bootstrap.js
+13
-3
dist/js/bootstrap.min.js
dist/js/bootstrap.min.js
+1
-1
docs-assets/js/raw-files.js
docs-assets/js/raw-files.js
+1
-1
js/affix.js
js/affix.js
+11
-1
js/tests/unit/affix.js
js/tests/unit/affix.js
+25
-0
No files found.
dist/js/bootstrap.js
View file @
c77740bd
...
...
@@ -1826,8 +1826,8 @@ if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery"
if
(
this
.
affixed
==
'
top
'
)
position
.
top
+=
scrollTop
if
(
typeof
offset
!=
'
object
'
)
offsetBottom
=
offsetTop
=
offset
if
(
typeof
offsetTop
==
'
function
'
)
offsetTop
=
offset
.
top
()
if
(
typeof
offsetBottom
==
'
function
'
)
offsetBottom
=
offset
.
bottom
()
if
(
typeof
offsetTop
==
'
function
'
)
offsetTop
=
offset
.
top
(
this
.
$element
)
if
(
typeof
offsetBottom
==
'
function
'
)
offsetBottom
=
offset
.
bottom
(
this
.
$element
)
var
affix
=
this
.
unpin
!=
null
&&
(
scrollTop
+
this
.
unpin
<=
position
.
top
)
?
false
:
offsetBottom
!=
null
&&
(
position
.
top
+
this
.
$element
.
height
()
>=
scrollHeight
-
offsetBottom
)
?
'
bottom
'
:
...
...
@@ -1836,10 +1836,20 @@ if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery"
if
(
this
.
affixed
===
affix
)
return
if
(
this
.
unpin
)
this
.
$element
.
css
(
'
top
'
,
''
)
var
affixType
=
'
affix
'
+
(
affix
?
'
-
'
+
affix
:
''
)
var
e
=
$
.
Event
(
affixType
+
'
.bs.affix
'
)
this
.
$element
.
trigger
(
e
)
if
(
e
.
isDefaultPrevented
())
return
this
.
affixed
=
affix
this
.
unpin
=
affix
==
'
bottom
'
?
this
.
getPinnedOffset
()
:
null
this
.
$element
.
removeClass
(
Affix
.
RESET
).
addClass
(
'
affix
'
+
(
affix
?
'
-
'
+
affix
:
''
))
this
.
$element
.
removeClass
(
Affix
.
RESET
)
.
addClass
(
affixType
)
.
trigger
(
$
.
Event
(
affixType
.
replace
(
'
affix
'
,
'
affixed
'
)))
if
(
affix
==
'
bottom
'
)
{
this
.
$element
.
offset
({
top
:
document
.
body
.
offsetHeight
-
offsetBottom
-
this
.
$element
.
height
()
})
...
...
dist/js/bootstrap.min.js
View file @
c77740bd
This diff is collapsed.
Click to expand it.
docs-assets/js/raw-files.js
View file @
c77740bd
This diff is collapsed.
Click to expand it.
js/affix.js
View file @
c77740bd
...
...
@@ -67,10 +67,20 @@
if
(
this
.
affixed
===
affix
)
return
if
(
this
.
unpin
)
this
.
$element
.
css
(
'
top
'
,
''
)
var
affixType
=
'
affix
'
+
(
affix
?
'
-
'
+
affix
:
''
)
var
e
=
$
.
Event
(
affixType
+
'
.bs.affix
'
)
this
.
$element
.
trigger
(
e
)
if
(
e
.
isDefaultPrevented
())
return
this
.
affixed
=
affix
this
.
unpin
=
affix
==
'
bottom
'
?
this
.
getPinnedOffset
()
:
null
this
.
$element
.
removeClass
(
Affix
.
RESET
).
addClass
(
'
affix
'
+
(
affix
?
'
-
'
+
affix
:
''
))
this
.
$element
.
removeClass
(
Affix
.
RESET
)
.
addClass
(
affixType
)
.
trigger
(
$
.
Event
(
affixType
.
replace
(
'
affix
'
,
'
affixed
'
)))
if
(
affix
==
'
bottom
'
)
{
this
.
$element
.
offset
({
top
:
document
.
body
.
offsetHeight
-
offsetBottom
-
this
.
$element
.
height
()
})
...
...
js/tests/unit/affix.js
View file @
c77740bd
...
...
@@ -22,4 +22,29 @@ $(function () {
ok
(
!
$affix
.
hasClass
(
'
affix
'
),
'
affix class was not added
'
)
})
test
(
'
should trigger affixed event after affix
'
,
function
()
{
stop
()
var
template
=
$
(
'
<div id="affixTarget"><ul><li>Please affix</li><li>And unaffix</li></ul></div><div id="affixAfter" style="height: 20000px; display:block;"></div>
'
)
template
.
appendTo
(
'
body
'
)
var
affixer
=
$
(
'
#affixTarget
'
).
affix
({
offset
:
$
(
'
#affixTarget ul
'
).
position
()
})
$
(
'
#affixTarget
'
)
.
on
(
'
affix.bs.affix
'
,
function
(
e
)
{
ok
(
true
,
'
affix event triggered
'
)
}).
on
(
'
affixed.bs.affix
'
,
function
(
e
)
{
ok
(
true
,
'
affixed event triggered
'
)
$
(
'
#affixTarget
'
).
remove
()
$
(
'
#affixAfter
'
).
remove
()
start
()
})
setTimeout
(
function
()
{
window
.
scrollTo
(
0
,
document
.
body
.
scrollHeight
)
setTimeout
(
function
()
{
window
.
scroll
(
0
,
0
)
},
0
)
},
0
)
})
})
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