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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
182db09e
Commit
182db09e
authored
Jun 23, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '34095-permalinks' into 'master'
Fix offset for fixed nav Closes #34095 See merge request !12365
parents
61064006
588d5564
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
app/assets/javascripts/lib/utils/common_utils.js
app/assets/javascripts/lib/utils/common_utils.js
+9
-2
app/assets/javascripts/merge_request_tabs.js
app/assets/javascripts/merge_request_tabs.js
+5
-1
No files found.
app/assets/javascripts/lib/utils/common_utils.js
View file @
182db09e
...
...
@@ -86,18 +86,25 @@
// This is required to handle non-unicode characters in hash
hash
=
decodeURIComponent
(
hash
);
var
fixedTabs
=
document
.
querySelector
(
'
.js-tabs-affix
'
);
var
fixedNav
=
document
.
querySelector
(
'
.navbar-gitlab
'
);
var
adjustment
=
0
;
if
(
fixedNav
)
adjustment
-=
fixedNav
.
offsetHeight
;
// scroll to user-generated markdown anchor if we cannot find a match
if
(
document
.
getElementById
(
hash
)
===
null
)
{
var
target
=
document
.
getElementById
(
'
user-content-
'
+
hash
);
if
(
target
&&
target
.
scrollIntoView
)
{
target
.
scrollIntoView
(
true
);
window
.
scrollBy
(
0
,
adjustment
);
}
}
else
{
// only adjust for fixedTabs when not targeting user-generated content
var
fixedTabs
=
document
.
querySelector
(
'
.js-tabs-affix
'
);
if
(
fixedTabs
)
{
window
.
scrollBy
(
0
,
-
fixedTabs
.
offsetHeight
)
;
adjustment
-=
fixedTabs
.
offsetHeight
;
}
window
.
scrollBy
(
0
,
adjustment
);
}
};
...
...
app/assets/javascripts/merge_request_tabs.js
View file @
182db09e
...
...
@@ -155,7 +155,10 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion';
scrollToElement
(
container
)
{
if
(
location
.
hash
)
{
const
offset
=
-
$
(
'
.js-tabs-affix
'
).
outerHeight
();
const
offset
=
0
-
(
$
(
'
.navbar-gitlab
'
).
outerHeight
()
+
$
(
'
.js-tabs-affix
'
).
outerHeight
()
);
const
$el
=
$
(
`
${
container
}
${
location
.
hash
}
:not(.match)`
);
if
(
$el
.
length
)
{
$
.
scrollTo
(
$el
[
0
],
{
offset
});
...
...
@@ -301,6 +304,7 @@ import BlobForkSuggestion from './blob/blob_fork_suggestion';
forceShow
:
true
,
});
anchor
[
0
].
scrollIntoView
();
window
.
gl
.
utils
.
handleLocationHash
();
// We have multiple elements on the page with `#note_xxx`
// (discussion and diff tabs) and `:target` only applies to the first
anchor
.
addClass
(
'
target
'
);
...
...
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