Closed mrspence closed 5 years ago
Hey Matt! I need to add something about this to the docs.
ScrollReveal responds to scroll
and resize
events, using the new public delegate()
instance method. This event handler is a close approximation of the legacy init()
method, and should help with your use case in a similar fashion.
By calling ScrollReveal().delegate()
manually, you force ScrollReveal to re-calculate element dimensions, along with container dimensions and scroll positions. It sounds like you may want to do this inside your LazySizes callback(s).
Nice one, works a charm - here's my resolving code for anyone who's interested:
$("body").on("lazyloaded load", function() {
window.sr.delegate();
// re-init scrollReveal
console.log("SR: Re-delegated");
});
I'm looking to use ScrollReveal with LazySizes (a lazy loading image library). When the images load, their dimenions sometimes change. This puts scroll reveal's plotted points of triggering out of sync, and becomes noticable the further down the page you scroll.
After browsing a little, I have come across a rellevant issue https://github.com/scrollreveal/scrollreveal/issues/52 but it appears the fix is no longer valid.
What would you suggest? Thank-you.
Environment