Skip to content

Instantly share code, notes, and snippets.

@bloodyowl
Forked from CyrilKrylatov/gist:5520294
Last active December 17, 2015 00:28
Show Gist options
  • Save bloodyowl/5520684 to your computer and use it in GitHub Desktop.
Save bloodyowl/5520684 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function($){
var headerOffset = $(".main-header").height()
, blockMenu = $(".block-menu")
, scrolled
, isBelow = false
, isCurrentlyBelow = false
$(window).scroll(function () {
scrolled = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
isCurrentlyBelow = scrolled > headerOffset
if(isCurrentlyBelow == isBelow) return
if(isCurrentlyBelow) {
blockMenu.addClass("is-mini").slideDown("slow")
isBelow = true
} else {
blockMenu.removeClass("is-mini")
isBelow = false
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment