Skip to content

Instantly share code, notes, and snippets.

@omurphy27
Created February 25, 2013 01:16
Show Gist options
  • Save omurphy27/5026685 to your computer and use it in GitHub Desktop.
Save omurphy27/5026685 to your computer and use it in GitHub Desktop.
JQUERY Flyout when scrolling down
// basically, the core of the function is do something once you reach a certain Y Offset relative to the browser window
$(document).ready(function () {
var $navPosTop = $('#navigation').position().top - 56;
var $flyout = $('.flyout');
if (!$.browser.msie || parseInt($.browser.version) > 8) { // this checks to see if the user is using IE8 or below and doesn't run the function if they are
$(window).scroll(function () {
if(pageYOffset <= $navPosTop){ // important note: in stupid ie9, you cannot use scrollY, gotta use pageYOffset instead
$flyout.animate({
right: '-176px'
}, 100);
}
if(pageYOffset > $navPosTop && $flyout.is(':not(:animated)')){
$flyout.animate({
right: '0'
}, 100);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment