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

when reload page, the component doesn't animated. #81

Open
abdullah-sameh opened this issue Jun 12, 2023 · 5 comments
Open

when reload page, the component doesn't animated. #81

abdullah-sameh opened this issue Jun 12, 2023 · 5 comments

Comments

@abdullah-sameh
Copy link

the component must be in the middle of page to be animated like in your demo page,The problem, that I can't make the header of page animated when reload page, i had to scroll to trigger.

@va1bhav-rawat
Copy link

In my case, I added offset={1} to the scroll animation component to run animation on entering the page.

@firstpersoncode
Copy link

In my case, I added offset={1} to the scroll animation component to run animation on entering the page.

Does this only work if scrollableParentSelector defaults to the document? I tried setting scrollableParentSelector to the parent div that contains the animated scroll elements, but it didn't work as expected. I had to scroll until I passed the element first, then scroll back, and finally scroll past the element again until it worked.

@kolokytp
Copy link

Any updates on this one? I seem to have the same problem as well

@amazingdudu
Copy link

same problem

@TwickE
Copy link

TwickE commented Nov 25, 2024

I also have the same problem, in the documentation is mentioned that there is a property called animatePreScroll that when set to true which is the default value animates the element if already visible when the page loads but it doesn't work. I manage to workaround the problem but the solution is kind of junky. I created a Hook that scrolls the page down 1px and back up to the top very fast when the page loads, the hook needs to be in the page where the component is used.

Hook:

import { useEffect } from 'react';

function useScrollUpdate() {
    useEffect(() => {
        window.scrollBy(0, 1);
        setTimeout(() => {
            window.scrollBy(0, -1);
        }, 50);
    }, []);
}

export default useScrollUpdate

But for this to work the ScrollAnimation component also needs the property animatePreScroll set to false which is kind of unintuitive.

Example:

<ScrollAnimation animatePreScroll={false} animateIn='fadeInLeft'>
    //Your animated component code here
</ScrollAnimation>

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

No branches or pull requests

6 participants