Created
June 24, 2014 12:19
-
-
Save JanMikes/97c7d77594a7fa0eb0ae to your computer and use it in GitHub Desktop.
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
var didScroll = false; | |
$(window).scroll(function() { | |
didScroll = true; | |
}); | |
setInterval(function() { | |
if ( didScroll ) { | |
didScroll = false; | |
/* | |
if ($(window).scrollTop() > 200) { | |
$("body > header").addClass("scrolled"); | |
} else { | |
$("body > header").removeClass("scrolled"); | |
} | |
*/ | |
if ($("section.projects").visible( true )) { | |
var newBgOffset = -930 + (Math.min(0, Math.max(-830, (($("section.projects").offset().top - $("section.projects").height()) - ($(window).scrollTop() + 200)- 260)/3)) - 100) * (-1); | |
$("section.projects").css("background-position", "center " + newBgOffset + "px"); | |
} | |
if ($(".background .slide").visible( true )) { | |
var newBgOffset = Math.max(0, $(window).scrollTop() / 3); | |
$(".background .slide img").css("top", newBgOffset+ "px"); | |
} | |
} | |
}, 25); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment