Created
May 14, 2013 21:28
-
-
Save vsync/5579704 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
$(document).ready(function(){ | |
// Cache the Window object | |
$window = $(window); | |
$('section[data-type="background"]').each(function(){ | |
var $bgobj = $(this); // assigning the object | |
$(window).scroll(function() { | |
if(($('#ikkunaone:in-viewport').length > 0)) { | |
var yPos = -100; | |
} | |
else { | |
// Scroll the background at var speed | |
// the yPos is a negative value because we're scrolling it UP! | |
var yPos = -($window.scrollTop() / $bgobj.data('speed')); | |
} | |
// Put together our final background position | |
var coords = '50% '+ yPos + 'px'; | |
// Move the background | |
$bgobj.css({ backgroundPosition: coords }); | |
}); // window scroll Ends | |
}); | |
}); | |
/* | |
* Create HTML5 elements for IE's sake | |
*/ | |
document.createElement("article"); | |
document.createElement("section"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment