Skip to content

Instantly share code, notes, and snippets.

@thierrypigot
Created August 21, 2015 10:01
Show Gist options
  • Save thierrypigot/46a1f71af58c2c83a9a7 to your computer and use it in GitHub Desktop.
Save thierrypigot/46a1f71af58c2c83a9a7 to your computer and use it in GitHub Desktop.
Add back to top in Genesis
/* ## Back to top
--------------------------------------------- */
.eemi-top:hover {
color: #fff !important;
background-color: rgba(0,0,0,0.8);
text-decoration: none;
}
.eemi-top {
display: none;
position: fixed;
bottom: 1rem;
right: 1rem;
width: 3.2rem;
height: 3.2rem;
line-height: 3.2rem;
font-size: 1.4rem;
color: #fff;
background-color: rgba(0,0,0,0.3);
text-decoration: none;
border-radius: 3.2rem;
text-align: center;
cursor: pointer;
}
jQuery(document).ready(function ($) {
// Back to top
var offset = 220;
var duration = 500;
$(window).scroll(function() {
if ($(this).scrollTop() > offset) {
$('.eemi-top').fadeIn(duration);
} else {
$('.eemi-top').fadeOut(duration);
}
});
$('.eemi-top').click(function(event) {
event.preventDefault();
$('html, body').animate({scrollTop: 0}, duration);
return false;
})
});
<?php
/**
* Back to top
*/
add_action( 'genesis_before', 'eemi_backToTop');
function eemi_backToTop()
{
if( !is_front_page() )
echo '<a href="#" class="eemi-top">↑</a>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment