Jump to content
Search Community

ScrollTrigger doesn't work on first load (have to reload page for it to be animated correctly)

mmarco
Moderator Tag

Go to solution Solved by mmarco,

Recommended Posts

Posted

Hi, im trying to make a Scrolltrigger animation with a grid, that has tiles in it, the tiles should come in from the bottom staggered as they are now, to recreate the problem i made a stackblitz demo:

https://stackblitz.com/edit/sveltejs-kit-template-default-tcgsr9?file=src%2Froutes%2Fstyles.css,src%2Froutes%2F%2Bpage.svelte,src%2Fcomponents%2FGridContainer.svelte

so when you first start the server and scroll down, the grid is placed way too low (where it would usually start when animating the scrolltrigger) but it doesnt animate, upon reloading the page, it animates as expected.
I put a green square below it to show the displacement at first, it happens every time, if i stop the server with Ctrl+C and start it up, on first load the grid is way too low and doesnt get animated. for the +page the Grid is inside two wrappers, the 2nd wrapper is there because of different components that i have in a column in between other components, i could solve it without the inner wrapper but im not sure if thats the problem, since ive tested it without it aswell...

I attached 2 Screenshots of what it looks like for me, the 1st one is after reloading, what it should look like and the 2nd one is when i first start the server, when it doesnt animate with Scrolltrigger


Any help or advice on whats wrong and how to fix it, is appreciated.
Thanks in Advance!

after_reload.png

first_page_load.png

  • Solution
Posted

i might've actually found the Issue, i accidentally left this: 

transition: transform 0.2s, background-color 0.2s, z-index 0.2s

in my CSS which i think messed with the Scrolltrigger, ill look into it some more to make sure though

Edit: seems to have actually fixed it... what a stupid mistake, lol

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...