Skip to content

Instantly share code, notes, and snippets.

@vsync
Last active December 17, 2015 08:19
Show Gist options
  • Save vsync/5579287 to your computer and use it in GitHub Desktop.
Save vsync/5579287 to your computer and use it in GitHub Desktop.
$(document).ready(function(){
// Cache the Window object
$window = $(window);
$('div[data-type="background"]').each(function(){
var $bgobj = $(this); // assigning the object
var i = 0;
$(window).scroll(function() {
if($('.jokuclassi:in-viewport').length > 0 && i == 0 ) {
var i = 1;
var yPos = jotain;
}
else {
var i = 0;
// 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