Skip to content

Commit ab3c39e

Browse files
authored
Merge pull request #1028 from Eshajha19/receipt-scroll
Add Scroll to Top Button on Receipt Page
2 parents 4023c5e + 83dc1de commit ab3c39e

3 files changed

Lines changed: 48 additions & 2 deletions

File tree

public/receipt.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,4 +471,31 @@ font-size:16px;
471471

472472
}
473473

474+
}#scrollTopBtn{
475+
position: fixed;
476+
bottom: 30px;
477+
right: 30px;
478+
background: linear-gradient(135deg,#00e6a8,#64ffda);
479+
color: #000;
480+
border: none;
481+
padding: 14px 16px;
482+
border-radius: 50%;
483+
font-size: 18px;
484+
cursor: pointer;
485+
display: none;
486+
z-index: 1000;
487+
box-shadow: 0 0 15px rgba(100,255,218,0.7);
488+
transition: all 0.3s ease;
489+
}
490+
491+
#scrollTopBtn:hover{
492+
transform: translateY(-4px) scale(1.1);
493+
box-shadow: 0 0 25px rgba(100,255,218,1);
494+
}
495+
496+
/* Dark Mode */
497+
498+
body.dark-mode #scrollTopBtn{
499+
background: linear-gradient(135deg,#64ffda,#00bfa5);
500+
color:white;
474501
}

public/receipt.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<title>Receipt Scanner | ExpenseFlow</title>
99

1010
<script src="https://cdn.jsdelivr.net/npm/tesseract.js@4/dist/tesseract.min.js"></script>
11-
11+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
1212
<link rel="stylesheet" href="receipt.css">
1313

1414
</head>
@@ -97,6 +97,10 @@ <h2>Saved Expenses</h2>
9797
<span id="popupMsg"></span>
9898

9999
</div>
100+
<!-- Scroll To Top Button -->
101+
<button id="scrollTopBtn" title="Go to top">
102+
<i class="fas fa-arrow-up"></i>
103+
</button>
100104
<script src="receipt.js"></script>
101105

102106
</body>

public/receipt.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,19 @@ popup.classList.remove("show");
251251

252252
},3000);
253253

254-
}
254+
}const scrollBtn = document.getElementById("scrollTopBtn");
255+
256+
window.onscroll = function () {
257+
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
258+
scrollBtn.style.display = "block";
259+
} else {
260+
scrollBtn.style.display = "none";
261+
}
262+
};
263+
264+
scrollBtn.addEventListener("click", function () {
265+
window.scrollTo({
266+
top: 0,
267+
behavior: "smooth"
268+
});
269+
});

0 commit comments

Comments
 (0)