jlmakes / scrollreveal

Animate elements as they scroll into view.
https://scrollrevealjs.org/
22.39k stars 2.26k forks source link

Reveal not working on refresh #17

Closed Koroeskohr closed 10 years ago

Koroeskohr commented 10 years ago

Hello there, I'm having trouble using this rather simple-to-use library : the revealing only appeared once on first load, then didn't show up at all. Here's what I used : http://koroeskohr.github.io/scrollRevealTests/tests/scrollReveal/

Maybe I'm just blind, I'd like some help! Awesome work, keep it up!

jlmakes commented 10 years ago

When I refresh the page, I see the initial reveals…

What’s odd, is that it seems everything reveals on first load (instead of when scrolled to). My suspicion is that by not having any declared height on any of the elements, the JavaScript views elements as "in viewport" before the HTTP requests complete.

"DOMContentLoaded fires when the DOM has been completely constructed. Certain elements may not have been completely defined or loaded, such as stylesheets, images, and iframes."

This is another issue that seems to stem from scrollReveal’s automatic instantiation upon the DOMContentLoaded event; the next release will address these types of issues.

This was addressed in #11

mattrothenberg commented 9 years ago

Hey, @jlmakes!

Any news on this one? I'm experiencing some serious weirdness when using scrollReveal with a custom Wordpress theme (https://github.com/roots/sage).

I'm using Gulp to serve a preview of my website / build assets, and it seems that anytime I modify the original scrollReveal function invocation (e.g., passing a configuration object to the function below), I have to rebuild the entire Javascript pipeline via Gulp to get the new changes to work. Until I rebuild, I get a scrollReveal is not defined error in the console.

window.sr = new scrollReveal();
jlmakes commented 9 years ago

This is a legacy issue. ScrollReveal no longer auto-instantiates, hopefully the theme author has maintained at least version 2 of ScrollReveal. I can’t offer any support for legacy issues (plus most of them have been fixed in later versions).

@mattrothenberg, but from what you’ve described, this sounds like an issue with the theme/gulp configuration… not a bug that can be fixed within ScrollReveal. I recommend opening an issue on the theme’s repository, as the theme author should be able to help you.

Edit: Also, there’s an existing issue for that theme which sounds related to what you’ve described.