pixelcog / parallax.js

Simple parallax scrolling effect inspired by Spotify.com implemented as a jQuery plugin
MIT License
3.53k stars 840 forks source link

.trigger('resize').trigger('scroll') not working #287

Open matmartinstudio opened 5 years ago

matmartinstudio commented 5 years ago

With ref to https://github.com/pixelcog/parallax.js#notes, I am finding it impossible to trigger a resize event in order to re-position images in parallax divs. I am having this issue on several sites – it can be seen currently at this site (scroll down to "Past Events", click on "Load More" and check image in div below).

I'm adding $(window).trigger('resize').trigger('scroll'); to the click event in the site footer and checking it with a console.log that's returning as expected. But the resize is doing nothing.

I should add that adding a slight delay to the whole, like this makes no difference:

setTimeout(function(){ $(window).trigger('resize').trigger('scroll'); }, 500);

Am I implementing this incorrectly?

Thanks.

felix-bohlin commented 4 years ago

Same. If I resize manually the image looks good, but not when I scroll. Adding the trigger events doesn't make a difference.

silviapeveri commented 3 years ago

Did anyone find a way to solve it? Resize works perfectly but I have te same problem on scroll.

woif00 commented 2 years ago

Had the same problem, fixed it by using the vanilla JS version: window.dispatchEvent(new Event('resize'));