Skip to content

Commit 96618ad

Browse files
authored
Merge pull request #88 from HarshitGourlariya/master
Issue with Duplicate Scripts ,no opening section , Missing Scroll Top…
2 parents 460a3c1 + b5b9cc0 commit 96618ad

File tree

3 files changed

+52
-24
lines changed

3 files changed

+52
-24
lines changed

index.html

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,19 @@ <h2 class="section-title" style="font-size: 3rem; text-align: center; margin-bot
179179
</form>
180180
<div id="form-status" style="text-align: center; margin-top: 30px; font-size: 1.2rem; display: none;">✅ Message sent successfully!</div>
181181
</div>
182+
183+
184+
</main>
185+
186+
<footer class="footer">
187+
<div class="container">
188+
<p>&copy; 2025 CodeCanvas. Open source project for the developer community.</p>
189+
<p>Built with ❤️ for showcasing amazing front-end projects</p>
190+
</div>
191+
</footer>
192+
<button id="scrollToTopBtn" title="Go to top"></button>
193+
194+
182195
</section>
183196

184197
<div id="message-overlay">
@@ -188,29 +201,7 @@ <h2 class="section-title" style="font-size: 3rem; text-align: center; margin-bot
188201
</div>
189202
</div>
190203
</main>
191-
192-
<footer class="footer">
193-
<div class="container">
194-
<p>&copy; 2025 CodeCanvas. Open source project for the developer community.</p>
195-
<p>Built with ❤️ for showcasing amazing front-end projects</p>
196-
</div>
197-
</footer>
198-
199-
<button id="scrollToTopBtn" title="Go to top"></button>
200-
201-
<script src="script.js"></script>
202-
<script>
203-
const toggle = document.getElementById('darkModeToggle');
204-
const body = document.body;
205-
const icon = document.getElementById('themeIcon');
206-
const savedTheme = localStorage.getItem('theme');
207-
if (savedTheme === 'dark') {
208-
body.classList.add('dark-theme');
209-
icon.textContent = '☀️';
210-
} else {
211-
icon.textContent = '🌙';
212-
}
213-
</script>
214204
<script src="script.js"></script>
205+
215206
</body>
216207
</html>

script.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
const sampleProjects = [
34
{
45
id: 1,
@@ -422,4 +423,18 @@ const sampleProjects = [
422423
grabCursor: true,
423424
speed: 600,
424425
});
425-
426+
//Scroll to top button functionality
427+
const scrollToTopBtn = document.getElementById("scrollToTopBtn");
428+
429+
// Show button when user scrolls down
430+
window.addEventListener("scroll", () => {
431+
scrollToTopBtn.style.display = window.scrollY > 300 ? "block" : "none";
432+
});
433+
434+
// Scroll to top smoothly
435+
scrollToTopBtn.addEventListener("click", () => {
436+
window.scrollTo({
437+
top: 0,
438+
behavior: "smooth"
439+
});
440+
});

style.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,3 +1202,25 @@ body.dark-theme button:hover {
12021202
}
12031203

12041204

1205+
#scrollToTopBtn {
1206+
position: fixed;
1207+
bottom: 2rem;
1208+
right: 2rem;
1209+
z-index: 999;
1210+
background-color: #667eea;
1211+
color: white;
1212+
border: none;
1213+
outline: none;
1214+
padding: 0.75rem 1rem;
1215+
border-radius: 50%;
1216+
font-size: 1.25rem;
1217+
cursor: pointer;
1218+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
1219+
display: none;
1220+
transition: background 0.3s ease, transform 0.3s ease;
1221+
}
1222+
1223+
#scrollToTopBtn:hover {
1224+
background-color: #5a67d8;
1225+
transform: scale(1.1);
1226+
}

0 commit comments

Comments
 (0)