Skip to content

Commit 5f3cd13

Browse files
committed
tweak scroll to anchor settings & css
This adds some css to ensure that scrolling to anchors is properly adjusted for the header. The 90px calculation is now no longer needed in the js - and has been removed. This also makes the scroll behaviour available to any anchor link.
1 parent 799e08d commit 5f3cd13

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

_layouts/api.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
{% endif %}
3636
{% endfor %}
3737
{% if render %}
38-
<a href="#method={{ name | slugify }}" class="scroll item">{{ name }}</a>
38+
<a href="#method_{{ name | slugify }}" class="scroll item">{{ name }}</a>
3939
{% endif %}
4040
{% endfor %}
4141
</div>
@@ -64,7 +64,7 @@ <h2>API Reference</h2>
6464
{% endif %}
6565
{% endfor %}
6666
{% if render %}
67-
<div id="method={{ name | slugify }}" class="api_method_wrapper">
67+
<div id="method_{{ name | slugify }}" class="api_method_wrapper">
6868
{{ method.description.full }}
6969
</div>
7070
{% endif %}

_layouts/guide.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<div id="{{ slug }}" class="subitems">
2525
{% for heading in guide.headings %}
2626
{% assign headingSlug = heading | slugify %}
27-
<a href="{{ url }}#{{ headingSlug }}" class="item secondary group-{{ slug }}{{ expanded }}">{{ heading }}</a>
27+
<a href="#{{ headingSlug }}" class="item secondary group-{{ slug }}{{ expanded }}">{{ heading }}</a>
2828
{% endfor %}
2929
</div>
3030
{% endif %}

_sass/_main.scss

-1
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,6 @@ section#content h1 {
702702
color: #30759c;
703703
}
704704
section#content h2 {
705-
padding-top: 15px;
706705
margin-top: 25px;
707706
}
708707
section#content p code {

css/main.scss

+12
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,15 @@
44
$baseurl: "{{ site.baseurl }}";
55
@import "pygments-github-style";
66
@import "main";
7+
8+
.rendered {
9+
h1, h2, h3, h4, div {
10+
&[id]:before {
11+
display: block;
12+
content: " ";
13+
margin-top: -80px;
14+
height: 80px;
15+
visibility: hidden;
16+
}
17+
}
18+
}

js/main.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
$(function () {
2-
$('a.scroll').click(function (e) {
2+
3+
$('a[href^="#"]').click(function (e) {
34
e.preventDefault();
45

56
var section = $(this).attr('href')
6-
, $scrollto = $(section + '-section');
7+
, $scrollto = $(section);
78

89
$('html,body').animate({
9-
scrollTop: $scrollto.offset().top - 90
10+
scrollTop: $scrollto.offset().top
11+
}, function () {
12+
window.location.hash = section;
1013
});
1114
});
1215

0 commit comments

Comments
 (0)