Skip to content

Instantly share code, notes, and snippets.

@celticwebdesign
Last active December 3, 2018 14:01
Show Gist options
  • Save celticwebdesign/b9faa30950e6a26aec211553c7a6a30a to your computer and use it in GitHub Desktop.
Save celticwebdesign/b9faa30950e6a26aec211553c7a6a30a to your computer and use it in GitHub Desktop.
var showingSlider = false;
function show_hide_div_on_scroll_jquery() {
if ($(window).scrollTop()>300)
{
if (!showingSlider){
showingSlider=true;
$('#header-hidden').animate({
top: 0,
opacity: 1,
}, 500);
}
}
else
{
if (showingSlider){
showingSlider=false;
$('#header-hidden').animate({
top: -150,
opacity: 0,
}, 500);
}
}
}
show_hide_div_on_scroll_jquery();
// https://tutorialdeep.com/knowhow/show-hide-div-on-scroll-jquery/
// https://stackoverflow.com/a/26171569
$(window).scroll(function() {
show_hide_div_on_scroll_jquery();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment