Created
July 24, 2012 16:17
-
-
Save imjakechapman/3170979 to your computer and use it in GitHub Desktop.
header parallex and title fade
This file contains hidden or 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
| <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