Skip to content

Instantly share code, notes, and snippets.

@JanMikes
Created June 24, 2014 12:19
Show Gist options
  • Save JanMikes/97c7d77594a7fa0eb0ae to your computer and use it in GitHub Desktop.
Save JanMikes/97c7d77594a7fa0eb0ae to your computer and use it in GitHub Desktop.
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