Jump to content
Search Community

Using from animation + pin ScrollTrigger make my div slightly goes to bottom from its default position

arifkrniawan

Go to solution Solved by mvaneijgen,

Recommended Posts

Posted

Can anyone help me? It's been a 3 days and I can't solve it.

I have some problem with my divs, its goes to bottom maybe 50px for no reason.

The first image is before I apply my GSAP, and the second one is after I apply my GSAP.

 

Also there is my Codepen, thankyou

Pasted image.png

Pasted image (2).png

See the Pen PwYYWwm by arifkrniawan (@arifkrniawan) on CodePen.

Posted
1 minute ago, arifkrniawan said:

Can anyone help me? It's been a 3 days and I can't solve it.

I have some problem with my divs, its goes to bottom maybe 50px for no reason.

The first image is before I apply my GSAP, and the second one is after I apply my GSAP.

 

Also there is my Codepen, thankyou

Pasted image.png

Pasted image (2).png

note: I still want my divs animated from bottom to top at opening page

  • Solution
Posted

Your issue is that you're animating your trigger element. Eg you animate sections on the y-axis 50px, but then also tell your ScrollTrigger to watch the y-axis of this same element to use as its calculations, which is causing the 50px jump. The easiest solution is to wrap your elements in another element called something like .trigger and use that as the trigger element, but that will require adjusting some of your CSS.

 

You might also what to look in to ScrollTrigger clamp(), on my screen your ScrollTrigger had already started on page load and with clamp you can tell it to wait until the visitor scrolls. In the demo below I've also converted your ScrollTrigger to be ints own object, if you don't need a tween. But your main issue is that you're animating your trigger element which is trowing of your animation by 50px and that is why you see the jump. Hope it helps and happy tweening! 

 

 

See the Pen VYZYrdL?editors=1010 by mvaneijgen (@mvaneijgen) on CodePen.

  • Like 1
Posted
On 11/29/2024 at 3:26 PM, mvaneijgen said:

Your issue is that you're animating your trigger element. Eg you animate sections on the y-axis 50px, but then also tell your ScrollTrigger to watch the y-axis of this same element to use as its calculations, which is causing the 50px jump. The easiest solution is to wrap your elements in another element called something like .trigger and use that as the trigger element, but that will require adjusting some of your CSS.

 

You might also what to look in to ScrollTrigger clamp(), on my screen your ScrollTrigger had already started on page load and with clamp you can tell it to wait until the visitor scrolls. In the demo below I've also converted your ScrollTrigger to be ints own object, if you don't need a tween. But your main issue is that you're animating your trigger element which is trowing of your animation by 50px and that is why you see the jump. Hope it helps and happy tweening! 

 

 

 

 

Greetings sir @mvaneijgen, Thankyou! it's working! I just add ".trigger" and styling the CSS

  • Like 1

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...