Skip to content

Instantly share code, notes, and snippets.

@taricco
Created April 28, 2022 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taricco/ea9efa78bd599ba640f8468106dea6f2 to your computer and use it in GitHub Desktop.
Save taricco/ea9efa78bd599ba640f8468106dea6f2 to your computer and use it in GitHub Desktop.
@link https://www.youtube.com/watch?v=oanr6o_Ty1c
/*** CSS
@link https://gist.github.com/gutenberghub/b278a76419c9f84b73c911b62156d2d4
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
.sticky-wrapper {
position: fixed;
top: 3%;
left: 0%;
z-index: 2;
width: 100% !important;
background: #fff;
}
/*** JavaScript
@link https://gist.github.com/gutenberghub/8ebf28acd020874020f02540f385acc8
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
$(document).ready(function(){
$(window).scroll(function(){
if($(this).scrollTop() >= 400){
$('.sticky-wrapper').fadeIn();
}else if($(this).scrollTop() === 0){
$('.sticky-wrapper').fadeIn();
} else{
$('.sticky-wrapper').fadeOut();
}
});
$('.sticky-wrapper').click(function(){
$('html, body').animate({scrollTop: 0}, 600);
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment