Created
February 25, 2013 01:16
-
-
Save omurphy27/5026685 to your computer and use it in GitHub Desktop.
JQUERY Flyout when scrolling down
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
// 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