mkwebworker
4/1/2014 - 10:46 AM

fix_chrome_bg_flickering.js

////// FIX CHROME BG FLICKERING BUG ////////////
if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
  // set background-attachment back to the default of 'scroll'
  jQuery('.parallax-1').css('background-attachment', 'scroll');

  // move the background-position according to the div's y position
  jQuery(window).scroll(function(){

      scrollTop = jQuery(window).scrollTop();
      photoTop = jQuery('.parallax-1').offset().top;
      distance = (photoTop - scrollTop);
      jQuery('.parallax-1').css('background-position', 'center ' + (distance*-1) + 'px');

  });
}