-
-
Save stryju/4c1bc6f27182627b987b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var debounce; | |
$(window).on('scroll', function (ev) { | |
if (debounce) { | |
clearTimeout(debounce); | |
} | |
debounce = setTimeout(function () { | |
if($(window).scrollTop() > secondaryNavTopPosition ) { | |
// ... | |
} else { | |
// ... | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var triggerTimeout; | |
$(window).on('scroll', function (ev) { | |
if (triggerTimeout) { | |
clearTimeout(triggerTimeout); | |
} | |
if($(window).scrollTop() > secondaryNavTopPosition ) { | |
secondaryNav.addClass('is-fixed'); | |
triggerTimeout = setTimeout(function() { | |
secondaryNav.addClass('animate-children'); | |
$('#cd-logo').addClass('slide-in'); | |
$('.cd-btn').addClass('slide-in'); | |
}, 60); | |
} else { | |
// ... | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var debounce; | |
$(window).on('scroll', function (ev) { | |
if (debounce) { | |
clearTimeout(debounce); | |
} | |
debounce = setTimeout(function () { | |
if($(window).scrollTop() > secondaryNavTopPosition ) { | |
secondaryNav.addClass('is-fixed'); | |
debounce = setTimeout(function() { | |
secondaryNav.addClass('animate-children'); | |
$('#cd-logo').addClass('slide-in'); | |
$('.cd-btn').addClass('slide-in'); | |
}, 60); | |
} else { | |
// ... | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = $(window), | |
logo = $('#cd-logo'), | |
btn = $('.cd-btn'), | |
secondaryNav = $('.cd-secondary-nav'), | |
secondaryNavTopPosition = secondaryNav.offset().top, | |
debounce; | |
win.on('scroll', function(){ | |
if (debounce) { | |
clearTimeout(debounce); | |
} | |
debounce = setTimeout(function () { | |
var collapsedTop = win.scrollTop() > secondaryNavTopPosition; | |
secondaryNav.toggleClass('is-fixed', collapsedTop); | |
debounce = setTimeout(function() { | |
secondaryNav.toggleClass('animate-children', collapsedTop); | |
logo.toggleClass('slide-in', collapsedTop); | |
btn.toggleClass('slide-in', collapsedTop); | |
}, 60); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment