简体   繁体   中英

Skrollr parallax breaks when resizing

I'm working on this site http://andreas-berg.dk/wordpress/ - inside the section with all the hexagones, I have set up a parallax effect on the background image. Right here: https://www.dropbox.com/s/swi9zab8nn5l1hj/Screenshot%202014-04-14%2010.12.22.png

If your browser window is maxed out there's nothing, but as soon as you're resizing the window, at little as 1 pixel, the background image gets pushed down. Any idea what's causing this to happen? It works fine if I resize it, refresh the browser, but that would be stupid to do everything the browser is resized and not user friendly.

This works fine for me in FireFox on mac, could you specify what browser you are using? Had to add answer instead of comment due to lack of reputation :)

I had a similar problem that I fixed by destroying skrollr and rerunning .init() on window resize. It created a lot of extra space on the bottom of my body unless I added forceHeight:false to it.

$(window).resize(function() {
  skroll.destroy();
  skroll = skrollr.init({forceHeight: false});
});

Just add following code to end of your parallax.js

document.getElementsByTagName("body")[0].onresize = function() {
setTimeout(function(){
    jQuery(window).trigger('resize').trigger('scroll');
}, 100);};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM