Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
7ce70dd5
Commit
7ce70dd5
authored
Sep 14, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dynamically create offset for sticky bar
parent
41068df7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
app/assets/javascripts/lib/utils/sticky.js
app/assets/javascripts/lib/utils/sticky.js
+25
-5
app/assets/stylesheets/pages/diff.scss
app/assets/stylesheets/pages/diff.scss
+2
-7
No files found.
app/assets/javascripts/lib/utils/sticky.js
View file @
7ce70dd5
export
const
isSticky
=
(
el
,
scrollY
,
stickyTop
)
=>
{
export
const
createPlaceholder
=
()
=>
{
const
placeholder
=
document
.
createElement
(
'
div
'
);
placeholder
.
classList
.
add
(
'
sticky-placeholder
'
);
return
placeholder
;
};
export
const
isSticky
=
(
el
,
scrollY
,
stickyTop
,
insertPlaceholder
)
=>
{
const
top
=
Math
.
floor
(
el
.
offsetTop
-
scrollY
);
const
top
=
Math
.
floor
(
el
.
offsetTop
-
scrollY
);
if
(
top
<=
stickyTop
)
{
if
(
top
<=
stickyTop
&&
!
el
.
classList
.
contains
(
'
is-stuck
'
))
{
const
placeholder
=
insertPlaceholder
?
createPlaceholder
(
el
)
:
null
;
const
heightBefore
=
el
.
offsetHeight
;
el
.
classList
.
add
(
'
is-stuck
'
);
el
.
classList
.
add
(
'
is-stuck
'
);
}
else
{
if
(
insertPlaceholder
)
{
el
.
parentNode
.
insertBefore
(
placeholder
,
el
.
nextElementSibling
);
placeholder
.
style
.
height
=
`
${
heightBefore
-
el
.
offsetHeight
}
px`
;
}
}
else
if
(
top
>
stickyTop
&&
el
.
classList
.
contains
(
'
is-stuck
'
))
{
el
.
classList
.
remove
(
'
is-stuck
'
);
el
.
classList
.
remove
(
'
is-stuck
'
);
if
(
insertPlaceholder
&&
el
.
nextElementSibling
.
classList
.
contains
(
'
sticky-placeholder
'
))
{
el
.
nextElementSibling
.
remove
();
}
}
}
};
};
export
default
(
el
)
=>
{
export
default
(
el
,
insertPlaceholder
=
true
)
=>
{
if
(
!
el
)
return
;
if
(
!
el
)
return
;
const
computedStyle
=
window
.
getComputedStyle
(
el
);
const
computedStyle
=
window
.
getComputedStyle
(
el
);
...
@@ -17,7 +37,7 @@ export default (el) => {
...
@@ -17,7 +37,7 @@ export default (el) => {
const
stickyTop
=
parseInt
(
computedStyle
.
top
,
10
);
const
stickyTop
=
parseInt
(
computedStyle
.
top
,
10
);
document
.
addEventListener
(
'
scroll
'
,
()
=>
isSticky
(
el
,
window
.
scrollY
,
stickyTop
),
{
document
.
addEventListener
(
'
scroll
'
,
()
=>
isSticky
(
el
,
window
.
scrollY
,
stickyTop
,
insertPlaceholder
),
{
passive
:
true
,
passive
:
true
,
});
});
};
};
app/assets/stylesheets/pages/diff.scss
View file @
7ce70dd5
...
@@ -451,7 +451,7 @@
...
@@ -451,7 +451,7 @@
}
}
.files
{
.files
{
margin-top
:
-
1px
;
margin-top
:
1px
;
.diff-file
:last-child
{
.diff-file
:last-child
{
margin-bottom
:
0
;
margin-bottom
:
0
;
...
@@ -586,11 +586,6 @@
...
@@ -586,11 +586,6 @@
top
:
76px
;
top
:
76px
;
}
}
+
.files
,
+
.alert
{
margin-top
:
1px
;
}
&
:not
(
.is-stuck
)
.diff-stats-additions-deletions-collapsed
{
&
:not
(
.is-stuck
)
.diff-stats-additions-deletions-collapsed
{
display
:
none
;
display
:
none
;
}
}
...
@@ -608,7 +603,7 @@
...
@@ -608,7 +603,7 @@
+
.files
,
+
.files
,
+
.alert
{
+
.alert
{
margin-top
:
32px
;
//
margin-top: 32px;
}
}
}
}
}
}
...
...
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