I haven't figured out a good way to create a minimal demo because my issue involves content that is loaded via ajax using the Wordpress plugin Ajax Load More. That said, I thought I'd try to explain the issue in words. If it makes no sense - ignore me!
Problem:
Parallax effect (data-scroll="0.9" for example) does not seem to work on content loaded via ajax.
Here is a page, for example (the images, which are actually little video thumbs) should have a parallax effect on them (like they do on the home page here.)
Attempted Solve(s):
First, I'm initiating the ScrollSmoother (so that it works and fires sitewide).
Next, I'm using a callback provided by Ajax Load More (almComplete) to fire a "ScrollTrigger.refresh();" once the ajax content has completely loaded.
However, it is not initiating the parallax effect on the image/video thumbs that were added via ajax. I've also put it inside a setTimeout of multiple seconds, and it doesn't seem to fire.
What does work:
What's interesting is that if instead of firing ScrollTrigger.refresh() in my ajax callback function, I reinitiate ScrollSmoother with...
let smoother = ScrollSmoother.create({
smooth: 1,
effects: true,
smoothTouch: 0.1,
normalizeScroll: true
});
...then the parallax effects work!
In all my reading, it seems that ScrollTrigger.refresh() should refire everything related to ScrollSmoother, but it doesn't seem to be working in this instance. Is there a different/better approach? Or, any thoughts as to why that order of events wouldn't refresh/fire my parallax elements?
As noted, I can get it working by using the method above of creating a smoother within my callback, but that feels wrong, so hoping to figure out what I'm doing wrong.
Thanks!