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

Allowing to set the initial state of the component #28

Open
dgopsq opened this issue May 24, 2018 · 0 comments
Open

Allowing to set the initial state of the component #28

dgopsq opened this issue May 24, 2018 · 0 comments

Comments

@dgopsq
Copy link

dgopsq commented May 24, 2018

Hello, I'm using this module to track an element at the top of the page (and so visible by default).
In the first load of the page this component always returns false and then the correct true, while if I reload the page when the component is not visible by default (i.e. if I reload while i'm in the middle of the page) I get only false which is correct.

You can see a replica here, and here's the code.

Edit: Okay, I checked the code and I see that the first false makes sense, since it's the default state, and I don't get a second value when I refresh while not seeing the element because the state remain false. This is quite a tricky thing, because I have an animation that triggers when isVisible === false, and so happens to trigger in the first load because of the default state. I tried to ignore that state but if a refresh happens in the middle of the page then the animation won't trigger.

I think allowing to set the initial state of the component could be an interesting solution, couldn't it?

@dgopsq dgopsq changed the title Odd behaviour with an element visible right on top. Allowing to set the initial state of the component May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants