APO-Epsilon/apo-website

View on GitHub
r8conf2016/js/parallax.js

Summary

Maintainability
A
0 mins
Test Coverage
/**
 * Parallax Scrolling Tutorial
 * For NetTuts+
 *  
 * Author: Mohiuddin Parekh
 *    http://www.mohi.me
 *     @mohiuddinparekh   
 */

$(document).ready(function(){
    // Cache the Window object
    $window = $(window);
                
   $('body[data-type="background"]').each(function(){
     var $bgobj = $(this); // assigning the object
                    
      $(window).scroll(function() {
                    
        // Scroll the background at var speed
        // the yPos is a negative value because we're scrolling it UP!                                
        var yMath = -($window.scrollTop() / ($bgobj.data('speed')) * 1.5);
        var yPos = +(Math.round(yMath + "e+" + 2)  + "e-" + 2);
        //var yPos = round(yMath,2);

        // 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");