Jump to content
Search Community

How can I create this effect using GSAP?

LhDev
Moderator Tag

Go to solution Solved by AntonioNB4,

Recommended Posts

Posted

Hi @LhDev welcome to the forum!

 

What have you tried already? Would love to see, so that we can better understand your thought process and see how we can better nudge you in the right direction.

 

Personally I find it much easier to test on places like Codepen, it allows you to just easily fork your work so that you can rapidly test new ideas and best of all you don't have to worry about your framework (or platform) throwing errors.

 

If you're new to GSAP check out this awesome getting started guide https://gsap.com/resources/get-started/

 

Hope it helps and happy tweening! 


Here is a starter template which loads all the plugins

See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen.

Posted

Hi @LhDevand welcome to the GSAP Forums!

 

Maybe these demos can provide a good starting point:

See the Pen wvZqwyg by GreenSock (@GreenSock) on CodePen.

 

See the Pen wvYVjvb by GreenSock (@GreenSock) on CodePen.

 

See the Pen xxmPjOv by GreenSock (@GreenSock) on CodePen.

 

You can check other ScrollTrigger demos in our demos page:

https://gsap.com/demos/?page=1&tags=ScrollTrigger

 

Hopefully this helps getting started

Happy Tweening!

  • Like 1
Posted

@mvaneijgen   @Rodrigo 

the problem is that I`m working with elementor in wrdpress I created this but the problem is that i need numbers to scrollup not just change color of them or change opacity of them and that where i found the big problem 

I the code here is almost doing what i need i just have the prblem of acheving the same effect as this page 

this is the code I ue right now

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ScrollTrigger.min.js"></script>

<script>
  gsap.registerPlugin(ScrollTrigger);

  const numbers = document.querySelectorAll('.number');
  const paragraphs = document.querySelectorAll(".container_p");

  paragraphs.forEach((paragraph, index) => {
    ScrollTrigger.create({
      trigger: paragraph,
      start: "bottom 2%",  
//       end: "bottom 2%",  
      onEnter: () => moveNumber(index),  
      onLeaveBack: () => moveNumber(index - 1), 
      scrub: true,  
			markers:true
    });
  });

  function moveNumber(index) {
    numbers.forEach((number, i) => {
      gsap.to(number, {
        y: i <= index ? "-100%" : "0%", 
        duration: 0.9,
        ease: "power1.out",
      });
    });
  }


//   gsap.set(numbers, { y: "100%" });
</script>

 

Screenshot 2024-10-04 173400.jpg

Posted

Yes, that is what is so great about Codepen, there you don't have to worry about elementor, you can just focus on getting the logic up and running and when you've got that it will be a breeze porting it over to elementor. 

 

Sorry we can't really help you if you don't provide a minimal demo, there is just no way to modify the code and you're currently only sharing 1/3 of the code that makes this possible. HTML and CSS are really important when working with GSAP. 

 

Keep in mind that the best thing to do when working with ScrollTrigger is to remove it! This seems counter intuitive, but ScrollTrigger is just animating something on scroll, so just focus on the animation at first and only when you're happy with the animation add ScrollTrigger back in. This way you can focus on one part at a time and it will save a lot of headache when debugging. 

 

 

 

Posted
5 hours ago, LhDev said:

but the problem is that i need numbers to scrollup not just change color of them or change opacity of them and that where i found the big problem 

It really doesn't matter, the animation you trigger is not really important, it could be moving up/down/left/right, change it's opacity, etc. The biggest challenge is timing everything correctly as the user scrolls up/down. The demos I linked were not intended to give you a copy/paste solution for your particular needs, just showing you the JS logic to achieve that. The rolling up/down effect is actually simple to achieve:

See the Pen gOVwbjK by GreenSock (@GreenSock) on CodePen.

 

Hopefully this clear things up

Happy Tweening!

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