Skip to content

Commit 1e0258a

Browse files
committed
OKRS24-235 Fixed 'back to top' button.
1 parent 34a886c commit 1e0258a

File tree

4 files changed

+43
-34
lines changed

4 files changed

+43
-34
lines changed

src/assets/css/style.css

+7-33
Original file line numberDiff line numberDiff line change
@@ -66,39 +66,6 @@ h6 {
6666
color: #012970;
6767
}
6868

69-
/*--------------------------------------------------------------
70-
# Back to top button
71-
--------------------------------------------------------------*/
72-
.back-to-top {
73-
position: fixed;
74-
visibility: hidden;
75-
opacity: 0;
76-
right: 15px;
77-
bottom: 15px;
78-
z-index: 99999;
79-
background: #4154f1;
80-
width: 40px;
81-
height: 40px;
82-
border-radius: 4px;
83-
transition: all 0.4s;
84-
}
85-
86-
.back-to-top i {
87-
font-size: 24px;
88-
color: #fff;
89-
line-height: 0;
90-
}
91-
92-
.back-to-top:hover {
93-
background: #6776f4;
94-
color: #fff;
95-
}
96-
97-
.back-to-top.active {
98-
visibility: visible;
99-
opacity: 1;
100-
}
101-
10269
/*--------------------------------------------------------------
10370
# Override some default Bootstrap stylings
10471
--------------------------------------------------------------*/
@@ -1389,3 +1356,10 @@ h6 {
13891356
.filter-description-popover {
13901357
margin-left: 1rem;
13911358
}
1359+
1360+
#btn-back-to-top {
1361+
position: fixed;
1362+
bottom: 20px;
1363+
right: 20px;
1364+
display: none;
1365+
}

src/assets/js/back_to_top.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//Get the button
2+
let mybutton = document.getElementById("btn-back-to-top");
3+
4+
// When the user scrolls down 20px from the top of the document, show the button
5+
window.onscroll = function () {
6+
scrollFunction();
7+
};
8+
9+
function scrollFunction() {
10+
if (
11+
document.body.scrollTop > 20 ||
12+
document.documentElement.scrollTop > 20
13+
) {
14+
mybutton.style.display = "block";
15+
} else {
16+
mybutton.style.display = "none";
17+
}
18+
}
19+
// When the user clicks on the button, scroll to the top of the document
20+
mybutton.addEventListener("click", backToTop);
21+
22+
function backToTop() {
23+
document.body.scrollTop = 0;
24+
document.documentElement.scrollTop = 0;
25+
}

src/templates/index.html

+10
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@
146146
</div>
147147
</div>
148148

149+
<button
150+
type="button"
151+
class="btn btn-danger btn-floating btn-lg"
152+
id="btn-back-to-top"
153+
>
154+
<i class="fas fa-arrow-up"></i>
155+
</button>
156+
149157
<footer class="py-3 my-4">
150158
<ul class="nav justify-content-center border-bottom pb-3 mb-3">
151159
<li class="nav-item">
@@ -177,5 +185,7 @@
177185
<script src="{% static 'floating-scrollbar/jquery.floatingscroll.min.js' %}"></script>
178186

179187
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>
188+
189+
<script src="{% static 'js/back_to_top.js' %}"></script>
180190
</body>
181191
</html>

src/templates/signals/signals.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ <h2 class="accordion-header" id="flush-heading_id_signal_availability">
276276
</div>
277277
<div class="col-9">
278278
<form methog="GET" id="orderByForm">
279-
<div class="row margin-bottom-1rem d-flex justify-content-end">
279+
<div class="row d-flex justify-content-end">
280280
<div class="col-6">
281281
<div class="input-group mb-3 d-flex justify-content-start">
282282
<span class="pt-05">

0 commit comments

Comments
 (0)