Skip to content

Commit

Permalink
Merge pull request #126 from Harshil-Gupta21/main
Browse files Browse the repository at this point in the history
Toggle Scroll Bar
  • Loading branch information
ayushichoudhary-19 authored Jan 18, 2024
2 parents c1ac04a + 22bfc33 commit e49ee3b
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 30 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified assets/.DS_Store
Binary file not shown.
Binary file added assets/head_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<link rel="stylesheet" href="styles.css" />
<link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />

<link rel="icon" href="assets/head_icon.png" />
<title>Portfolio Website</title>
</head>

Expand Down
34 changes: 34 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,37 @@ window.onload = function () {
css.innerHTML = ".typewrite > .wrap { border-right: 0.08em solid #fff}";
document.body.appendChild(css);
};

// ----------Toggle Scroll Bar ------------

window.addEventListener("scroll", () => {
showScroll();
});

const onScrollStop = (showScroll) => {
let scrolling;
window.addEventListener(
"scroll",
() => {
clearTimeout(scrolling);
scrolling = setTimeout(() => {
showScroll();
}, 500);
},
false
);
};

onScrollStop(() => {
hideScroll();
});

function showScroll() {
let doc = document.querySelector("body");
doc.classList.remove("hide-scroll");
}

function hideScroll() {
let doc = document.querySelector("body");
doc.classList.add("hide-scroll");
}
36 changes: 6 additions & 30 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -824,34 +824,6 @@ details:has(input:checked) label::before {
flex-wrap: wrap;
}

.scroll-up-btn {
position: fixed;
height: 45px;
width: 42px;
background: #2980b9;
right: 30px;
bottom: 10px;
text-align: center;
line-height: 45px;
color: #fff;
z-index: 9999;
font-size: 30px;
border-radius: 6px;
border-bottom-width: 2px;
cursor: pointer;
opacity: 0;
pointer-events: none;
transition: all 0.3s ease;
}
.scroll-up-btn.show {
bottom: 30px;
opacity: 1;
pointer-events: auto;
}
.scroll-up-btn:hover {
filter: brightness(90%);
}

.scroll-up-btn {
position: fixed;
height: 45px;
Expand Down Expand Up @@ -1176,7 +1148,7 @@ h2 {
/* -------------Testimonials Ends---------- */

::-webkit-scrollbar {
width: 12px;
width: 8px;
}

::-webkit-scrollbar:hover {
Expand All @@ -1185,7 +1157,11 @@ h2 {

::-webkit-scrollbar-thumb {
background-color: #3498db;
border-radius: 6px;
border-radius: 4px;
}

.hide-scroll::-webkit-scrollbar-thumb {
display: none;
}

/* contact-item */
Expand Down

0 comments on commit e49ee3b

Please sign in to comment.