Skip to content

Instantly share code, notes, and snippets.

@amici-fos
Created September 20, 2016 10:07
Show Gist options
  • Save amici-fos/05ca4760821121341b97c5d85daa2ba9 to your computer and use it in GitHub Desktop.
Save amici-fos/05ca4760821121341b97c5d85daa2ba9 to your computer and use it in GitHub Desktop.
if ($( ".subtabs" )){
$( window ).scroll(function() {
var p = $( ".subtabs" );
var offset = p.offset();
var viewableOffset = p.offset().top - $(window).scrollTop();
console.log($(window).scrollTop());
if(viewableOffset<=20){
p.addClass("fixed");
}
if ($(window).scrollTop()<60){
p.removeClass("fixed");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment