Skip to content

Commit 1a4b11a

Browse files
Scoll Up Btn 😎
1 parent d1dfb34 commit 1a4b11a

File tree

5 files changed

+142
-139
lines changed

5 files changed

+142
-139
lines changed

css/scroll.css

Lines changed: 0 additions & 115 deletions
This file was deleted.

css/style.css

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
* {
2+
padding: 0;
3+
margin: 0;
4+
box-sizing: border-box;
5+
font-family: "Poppins", sans-serif;
6+
}
7+
8+
html {
9+
scroll-behavior: smooth;
10+
}
111

212
body {
313
display: flex;
@@ -178,4 +188,111 @@
178188
margin-top: auto;
179189
}
180190

181-
/* ENDS ------------->>>>>>>>> */
191+
/* ENDS ------------->>>>>>>>> */
192+
193+
/* Scroll Button Style */
194+
195+
#scroll {
196+
position: fixed;
197+
bottom: 20px;
198+
right: 10px;
199+
height: 55px;
200+
width: 55px;
201+
display: none;
202+
place-items: center;
203+
border-radius: 50%;
204+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
205+
cursor: pointer;
206+
}
207+
208+
#scroll:hover {
209+
box-shadow: 0 0 150px 10px #0366d6;
210+
}
211+
212+
#scroll-bar {
213+
display: block;
214+
height: calc(100% - 10px);
215+
width: calc(100% - 10px);
216+
background-color: #c3ddfa;
217+
border-radius: 50%;
218+
display: grid;
219+
place-items: center;
220+
font-size: 28px;
221+
color: #001a2e;
222+
}
223+
224+
.pulse {
225+
margin: 0 auto;
226+
border-radius: 100px;
227+
position: absolute;
228+
left: -5.2px;
229+
top: -5.2px;
230+
z-index: 0;
231+
background-color: transparent;
232+
opacity: 0;
233+
width: 66px;
234+
height: 66px;
235+
border: 6px solid #0366d6;
236+
-webkit-border-radius: 100px;
237+
-moz-border-radius: 100px;
238+
-o-border-radius: 100px;
239+
-ms-border-radius: 100px;
240+
border-radius: 100px;
241+
-webkit-animation: pulse 1s linear infinite 0.3s;
242+
-moz-animation: pulse 1s linear infinite 0.3s;
243+
border-image: initial;
244+
}
245+
246+
@-webkit-keyframes pulse {
247+
0% {
248+
-webkit-transform: scale(0);
249+
opacity: 0;
250+
}
251+
252+
8% {
253+
-webkit-transform: scale(0);
254+
opacity: 0;
255+
}
256+
257+
15% {
258+
-webkit-transform: scale(0.1);
259+
opacity: 1;
260+
}
261+
262+
30% {
263+
-webkit-transform: scale(0.5);
264+
opacity: 1;
265+
}
266+
267+
100% {
268+
opacity: 0;
269+
-webkit-transform: scale(1.5);
270+
}
271+
}
272+
273+
@-moz-keyframes pulse {
274+
0% {
275+
-webkit-transform: scale(0);
276+
opacity: 0;
277+
}
278+
279+
8% {
280+
-webkit-transform: scale(0);
281+
opacity: 0;
282+
}
283+
284+
15% {
285+
-webkit-transform: scale(0.1);
286+
opacity: 1;
287+
}
288+
289+
30% {
290+
-webkit-transform: scale(0.5);
291+
opacity: 1;
292+
}
293+
294+
100% {
295+
opacity: 0;
296+
-webkit-transform: scale(1.5);
297+
}
298+
}

index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.17/dist/tailwind.min.css" rel="stylesheet">
77
<link href="css/style.css" rel="stylesheet">
8-
<link rel="stylesheet" href="./css/scroll.css">
98
<title>GitHub Automation Scripts 🤖</title>
109
<style>
1110

@@ -205,7 +204,6 @@ <h1 class="text-xl font-semibold mb-4">License</h1>
205204
</div>
206205

207206
<script src="js/scripts.js"></script>
208-
<script src="./js/scroll.js"></script>
209207
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/js/all.min.js"></script>
210208
</body>
211209
</html>

js/scripts.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,27 @@ function openTab(evt, tabName) {
1515
document.getElementById(tabName).style.display = "block";
1616
evt.currentTarget.classList.add("bg-gray-300");
1717
evt.currentTarget.classList.add("active:bg-gray-300");
18-
}
18+
}
19+
20+
// Functioning of the scroll up button
21+
22+
let calcScrollValue = () => {
23+
let scrollProgress = document.getElementById("scroll");
24+
let pos = document.documentElement.scrollTop;
25+
let calcHeight =
26+
document.documentElement.scrollHeight -
27+
document.documentElement.clientHeight;
28+
let scrollValue = Math.round((pos * 100) / calcHeight);
29+
if (pos > 100) {
30+
scrollProgress.style.display = "grid";
31+
} else {
32+
scrollProgress.style.display = "none";
33+
}
34+
scrollProgress.addEventListener("click", () => {
35+
document.documentElement.scrollTop = 0;
36+
});
37+
scrollProgress.style.background = `conic-gradient(#0366d6 ${scrollValue}%, #d7d7d7 ${scrollValue}%)`;
38+
};
39+
40+
window.onscroll = calcScrollValue;
41+
window.onload = calcScrollValue;

js/scroll.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)