Skip to content

Instantly share code, notes, and snippets.

@imjakechapman
Created July 24, 2012 16:17
Show Gist options
  • Select an option

  • Save imjakechapman/3170979 to your computer and use it in GitHub Desktop.

Select an option

Save imjakechapman/3170979 to your computer and use it in GitHub Desktop.
header parallex and title fade
<script>
$(document).ready(function(){
// global vars
var header = $('.header');
var HeaderWrap = $('.header-inner');
var windowScroll;
$(window).scroll(function(){
headingParallax();
});
function headingParallax() {
// how much have we scrolled?
windowScroll = $(window).scrollTop();
// parallax then fade out
HeaderWrap.css({
'margin-top' : -(windowScroll/3)+"px",
'opacity' : 1-(windowScroll/200)
});
// parallax background image
header.css({
'background-position' : 'center ' + (-windowScroll/2)+"px",
});
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment