Created
April 17, 2016 07:46
-
-
Save ciases/190c69dcd58be2574ff8eded779ce012 to your computer and use it in GitHub Desktop.
Easy parallax scroll effect
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
// https://bolt.cm/ | |
// MAKE TOPIMAGE SCROLL SLOWER FOR PARALLAX EFFECT | |
$(window).scroll(function () { | |
$('header').css('backgroundPosition', '0px ' + (posTop() / 2) + 'px'); | |
}); | |
// FIX FOR SCROLLPOS IN ALL BROWSERS | |
function posTop() { | |
return typeof window.pageYOffset != 'undefined' ? window.pageYOffset: document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop? document.body.scrollTop:0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment