Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reveal only works on resize? #298

Closed
ambidustrious opened this issue Sep 28, 2016 · 10 comments
Closed

Reveal only works on resize? #298

ambidustrious opened this issue Sep 28, 2016 · 10 comments
Labels

Comments

@ambidustrious
Copy link

ambidustrious commented Sep 28, 2016

I have the animation applied to one item as of now. It won't work on scroll... only if I resize the browser to make it taller? I'm sure it's something simple, but can't seem to track it down. I've also tried to remove all other scripts to check for a conflict, but that didn't help either.

@ambidustrious
Copy link
Author

ambidustrious commented Sep 28, 2016

In case anyone is curious... it was an issue with overflow-x: hidden being assigned to the html and body tags. I changed it to overflow-x: initial and the problem was solved.

@jlmakes jlmakes changed the title What am I missing? Reveal only works on resize? Oct 3, 2016
@edoardoVD
Copy link

edoardoVD commented Jun 12, 2017

Yup I had the same issue, with this overflow-x at the html, body level

@jlmakes any idea why scrollreveals stop working when this overflow-x is set to hidden ?

@jlmakes
Copy link
Owner

jlmakes commented Jun 12, 2017

@edoardoVD If you can recreate this problem using JSBin (or similar), I will spend some time debugging it. Please be sure to specify what operating system, browser version and library version you are using.

@edoardoVD
Copy link

edoardoVD commented Jun 13, 2017

@jlmakes thanks for the offer in looking into this

Two very basic pure JS samples:

This one does NOT behave as expected: http://js.do/code/jsrtest
This one does: https://jsfiddle.net/qgbajp73/

Also I'm using:

  • Angular 2
  • ng-scrollreveal (ScrollReveal v3.3.5)
  • Windows 10
  • Chrome, Edge and Firefox (latest)

I guess it has to do on how things are rendered, or timing on when ScrollReveal executes code to start getting its container, positions, etc...

@jlmakes
Copy link
Owner

jlmakes commented Jun 13, 2017

@edoardoVD You need body { height: 100% }, otherwise the <body> element is the entire height of the content, not the height of the window.

You can inspect your first demo, and see the body is almost 4000px tall. This causes everything to be "visible" (relative to the container) on page load, causing this issue where elements are revealed before they are scrolled to.

@edoardoVD
Copy link

edoardoVD commented Jun 14, 2017

@jlmakes thanks so much for troubleshooting this so fast, I'll look into more detail on my Angular 2 project, and see what might be causing a body height resize or other manipulation while rendering the view, while that specific CSS property is set (overflow-x: hidden)

Thank you for your time!

Just as a comment reference this is the behavior:

26942457-5ee52400-4c3f-11e7-8dc7-f96038acfdab

@jlmakes
Copy link
Owner

jlmakes commented Jun 14, 2017

@edoardoVD I’m actually not sure what scenarios would conflict with height: 100% set on the <body>... this has come up a few times before, and I’m considering just baking the behavior into ScrollReveal (so it adds that style to the body for you).

@jlmakes jlmakes added Bug and removed Question labels Jun 26, 2017
@dbarrett24
Copy link

@jlmakes Getting this same bug on the last section of my page. Only shows on window resize.
I've tried height: 100% and the overflow-x: hidden fixes mentioned in this thread but with no luck.

Here is the site for reference:
dave-barrett.com

@jlmakes
Copy link
Owner

jlmakes commented Feb 25, 2021

@dbarrett24 ScrollReveal captures element sizes when initialized, and on resize. That means when you are first calling ScrollReveal() the page must have its final dimensions. (For example, after really tall images have fully loaded.)

I would try deferring when you first call ScrollReveal... or if you don't mind using currently undocumented API, you can call ScrollReveal().delegate() after your page has completed loading. (The delegate is what scroll, resize and initialization invoke under the hood.)

Either way, ScrollReveal should do what you expect once it has an accurate cache of element sizes.

@RuyVictor
Copy link

@jlmakes This bug is still happening, it only works when you resize the viewport, add this after the ScrollReveal() class instance.

setTimeout(() => ScrollReveal().delegate(), 100);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants