-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a scroll back to top button #216
Changes from 12 commits
639681b
1325ec1
3009709
d80f047
6183c86
fcbeefa
170ea15
01ba74f
49b218c
173ac3b
1022f46
f5a9d44
3d2e4fc
58564a7
99fdc08
b48429f
2113b7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,12 @@ <h2>Language</h2> | |
</div> | ||
</div> | ||
|
||
|
||
<h2 style="text-align: center; "><a href="/all">See all</a></h2> | ||
|
||
<a href="#the-top" class="stt" id="stt" title="scroll to top">Back To Top</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd opt for a class here, rather than an id. We don't need both. If there's good cause for the id instead, I'm open to it, but its redundant to have both. I'd also suggest it be spelled out to be more semantic and descriptive. So rather than a class or id of: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
<script src="scroll.js"></script> | ||
|
||
TimidRobot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<h2 style="text-align: center"><a href="/all">See all</a></h2> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
document.addEventListener("DOMContentLoaded", function() { | ||
let stt = document.getElementById("stt"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the element in question is changed to only have a class, you'd need to use a querySelector to grab it by class here, but if not then disregard. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
window.onscroll = function() { | ||
if (window.scrollY > 400) { | ||
stt.style.display = "block"; | ||
} else { | ||
stt.style.display = "none"; | ||
} | ||
}; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SamarthShukla17 I think you've accidentally added a bunch of html here you didn't mean to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I'm sorry about that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reverted the changes in the commit, kindly review.