Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
masonstrap
Commits
f750ad35
Commit
f750ad35
authored
Feb 07, 2013
by
Thomas Park
Browse files
preview pages: get rid of content jumps when subnav -> subnav-fixed
parent
14dc685d
Changes
2
Hide whitespace changes
Inline
Side-by-side
css/bootswatch.css
View file @
f750ad35
...
@@ -24,6 +24,10 @@ section {
...
@@ -24,6 +24,10 @@ section {
font-size
:
54px
;
font-size
:
54px
;
}
}
.subhead
>
div
:first-child
{
min-height
:
200px
;
}
.subnav
{
.subnav
{
margin-bottom
:
60px
;
margin-bottom
:
60px
;
width
:
100%
;
width
:
100%
;
...
...
js/application.js
View file @
f750ad35
...
@@ -4,9 +4,12 @@
...
@@ -4,9 +4,12 @@
// fix sub nav on scroll
// fix sub nav on scroll
var
$win
=
$
(
window
),
var
$win
=
$
(
window
),
$body
=
$
(
'
body
'
),
$nav
=
$
(
'
.subnav
'
),
$nav
=
$
(
'
.subnav
'
),
navHeight
=
$
(
'
.navbar
'
).
first
().
height
(),
navHeight
=
$
(
'
.navbar
'
).
first
().
height
(),
navTop
=
$
(
'
.subnav
'
).
length
&&
$
(
'
.subnav
'
).
offset
().
top
-
navHeight
,
subnavHeight
=
$
(
'
.subnav
'
).
first
().
height
(),
subnavTop
=
$
(
'
.subnav
'
).
length
&&
$
(
'
.subnav
'
).
offset
().
top
-
navHeight
,
marginTop
=
parseInt
(
$body
.
css
(
'
margin-top
'
),
10
);
isFixed
=
0
;
isFixed
=
0
;
processScroll
();
processScroll
();
...
@@ -15,12 +18,15 @@
...
@@ -15,12 +18,15 @@
function
processScroll
()
{
function
processScroll
()
{
var
i
,
scrollTop
=
$win
.
scrollTop
();
var
i
,
scrollTop
=
$win
.
scrollTop
();
if
(
scrollTop
>=
navTop
&&
!
isFixed
)
{
if
(
scrollTop
>=
subnavTop
&&
!
isFixed
)
{
isFixed
=
1
;
isFixed
=
1
;
$nav
.
addClass
(
'
subnav-fixed
'
);
$nav
.
addClass
(
'
subnav-fixed
'
);
}
else
if
(
scrollTop
<=
navTop
&&
isFixed
)
{
$body
.
css
(
'
margin-top
'
,
marginTop
+
subnavHeight
+
'
px
'
);
}
else
if
(
scrollTop
<=
subnavTop
&&
isFixed
)
{
isFixed
=
0
;
isFixed
=
0
;
$nav
.
removeClass
(
'
subnav-fixed
'
);
$nav
.
removeClass
(
'
subnav-fixed
'
);
$body
.
css
(
'
margin-top
'
,
marginTop
+
'
px
'
);
}
}
}
}
...
...
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