Skip to content

Commit

Permalink
#80 created the scroll to top button (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithpabbati authored and jywarren committed Feb 15, 2019
1 parent a05c597 commit 73d1528
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
26 changes: 25 additions & 1 deletion examples/demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,28 @@ h1, h2, .section h3 {
.header {
text-align: center;
}

#back2Top {
width: 40px;
line-height: 40px;
overflow: hidden;
z-index: 999;
display: none;
cursor: pointer;
-moz-transform: rotate(270deg);
-webkit-transform: rotate(270deg);
-o-transform: rotate(270deg);
-ms-transform: rotate(270deg);
transform: rotate(270deg);
position: fixed;
bottom: 50px;
right: 0;
background-color: #DDD;
color: #555;
text-align: center;
font-size: 30px;
text-decoration: none;
}
#back2Top:hover {
background-color: #DDF;
color: #000;
}
20 changes: 19 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,24 @@ <h2 class="contributors-head">Contributors</h2>
</footer>

<script type="text/javascript">
/*Scroll to top when arrow up clicked BEGIN*/
$(window).scroll(function() {
var height = $(window).scrollTop();
if (height > 100) {
$('#back2Top').fadeIn();
} else {
$('#back2Top').fadeOut();
}
});
$(document).ready(function() {
$("#back2Top").click(function(event) {
event.preventDefault();
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});

});
/*Scroll to top when arrow up clicked END*/

var toolbox;

Expand Down Expand Up @@ -256,7 +274,7 @@ <h2 class="contributors-head">Contributors</h2>


</script>

<a id="back2Top" title="Back to top" href="#">&#10148;</a>
</body>

</html>

0 comments on commit 73d1528

Please sign in to comment.