Skip to content

Commit

Permalink
Merge pull request #17 from rbhatia46/master
Browse files Browse the repository at this point in the history
Integrate back to top button
  • Loading branch information
giannisdaras authored Jan 18, 2019
2 parents 7dfb513 + a571e16 commit 3833a68
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
42 changes: 42 additions & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,48 @@ header .logo h1 a {
color: #fff;
}

#return-to-top {
position: fixed;
bottom: 20px;
right: 20px;
background: rgb(0, 0, 0);
background: rgba(0, 0, 0, 0.7);
width: 50px;
height: 50px;
z-index: 9999;
display: block;
text-decoration: none;
-webkit-border-radius: 35px;
-moz-border-radius: 35px;
border-radius: 35px;
display: none;
-webkit-transition: all 0.3s linear;
-moz-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
}
#return-to-top i {
color: #fff;
margin: 0;
position: relative;
left: 16px;
top: 13px;
font-size: 19px;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
}
#return-to-top:hover {
background: rgba(0, 0, 0, 0.9);
}
#return-to-top:hover i {
color: #fff;
}


/* header .logo h1 a:hover {
color: #ccc;
} */
Expand Down
14 changes: 14 additions & 0 deletions static/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,3 +594,17 @@ function onDOMContentLoaded(){
}

document.addEventListener('DOMContentLoaded', onDOMContentLoaded);

// ===== Scroll to Top Button ====
$(window).scroll(function() {
if ($(this).scrollTop() >= 100) { // If page is scrolled more than 100px
$('#return-to-top').fadeIn(200); // Fade in the arrow
} else {
$('#return-to-top').fadeOut(200); // Else fade out the arrow
}
});
$('#return-to-top').click(function() { // When arrow is clicked
$('body,html').animate({
scrollTop : 0 // Scroll to top of body
}, 500);
});
3 changes: 3 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ <h1><a href="/"> NLPBuddy - Open Source Text Analysis Tool</a></h1>
</div>
</header>

<!-- Return to top Arrow -->
<a href="javascript:" id="return-to-top"><i class="fa fa-chevron-up"></i></a>

{% block content %}

{% endblock %}
Expand Down

0 comments on commit 3833a68

Please sign in to comment.