Skip to content
Snippets Groups Projects
Commit 71464c18 authored by Simon Egli's avatar Simon Egli
Browse files

Fading the "Scroll to Top" button in and out


Previously the "scroll to Top"-button was always shown.
In my opinion this makes little sense when you are already at the top
and may even lead to confusion (nothing happens when you press the button,
when at top).
So this change will fade the button in and out depending on where you are.
It is leveraging the already implemented scrollPage function.

Signed-off-by: default avatarSimon Egli <deadolus@gmail.com>
parent 0c71c750
No related branches found
No related tags found
No related merge requests found
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
</footer> </footer>
<!-- Scroll to Top Button (Only visible on small and extra-small screen sizes) --> <!-- Scroll to Top Button (Only visible on small and extra-small screen sizes) -->
<div class="scroll-top page-scroll visible-xs visible-sm"> <div class="scroll-top page-scroll hidden-sm hidden-xs hidden-lg hidden-md">
<a class="btn btn-primary" href="#page-top"> <a class="btn btn-primary" href="#page-top">
<i class="fa fa-chevron-up"></i> <i class="fa fa-chevron-up"></i>
</a> </a>
......
...@@ -28,9 +28,15 @@ var cbpAnimatedHeader = (function() { ...@@ -28,9 +28,15 @@ var cbpAnimatedHeader = (function() {
var sy = scrollY(); var sy = scrollY();
if ( sy >= changeHeaderOn ) { if ( sy >= changeHeaderOn ) {
classie.add( header, 'navbar-shrink' ); classie.add( header, 'navbar-shrink' );
} $('.scroll-top').removeClass('hidden-sm hidden-xs');
$('.scroll-top').fadeIn(500);
}
else { else {
classie.remove( header, 'navbar-shrink' ); classie.remove( header, 'navbar-shrink' );
$('.scroll-top').fadeOut(500, function() {
$('.scroll-top').addClass('hidden-sm hidden-xs');
});
} }
didScroll = false; didScroll = false;
} }
...@@ -41,4 +47,4 @@ var cbpAnimatedHeader = (function() { ...@@ -41,4 +47,4 @@ var cbpAnimatedHeader = (function() {
init(); init();
})(); })();
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment