Skip to content

Instantly share code, notes, and snippets.

@mkwebworker
Created April 1, 2014 10:46
Show Gist options
  • Save mkwebworker/9911700 to your computer and use it in GitHub Desktop.
Save mkwebworker/9911700 to your computer and use it in GitHub Desktop.
////// 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');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment