Skip to content

Commit b23ec91

Browse files
shawnheidejorisvandenbossche
authored andcommitted
Closes #13688: added scroll to top button to footer block in theme (#13689)
1 parent 1cd1026 commit b23ec91

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

doc/source/themes/nature_with_gtoc/layout.html

+34
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,37 @@ <h3 style="margin-top: 1.5em;">{{ _('Search') }}</h3>
6161
</div>
6262
</div>
6363
{%- endblock %}
64+
65+
{%- block footer %}
66+
<style type="text/css">
67+
.scrollToTop {
68+
text-align: center;
69+
font-weight: bold;
70+
position: fixed;
71+
bottom: 60px;
72+
right: 40px;
73+
display: none;
74+
}
75+
</style>
76+
<a href="#" class="scrollToTop">Scroll To Top</a>
77+
<script type="text/javascript">
78+
$(document).ready(function() {
79+
//Check to see if the window is top if not then display button
80+
$(window).scroll(function() {
81+
if ($(this).scrollTop() > 200) {
82+
$('.scrollToTop').fadeIn();
83+
} else {
84+
$('.scrollToTop').fadeOut();
85+
}
86+
});
87+
88+
//Click event to scroll to top
89+
$('.scrollToTop').click(function() {
90+
$('html, body').animate({
91+
scrollTop: 0
92+
}, 500);
93+
return false;
94+
});
95+
});
96+
</script>
97+
{% endblock %}

0 commit comments

Comments
 (0)