Jump to content
Search Community

how to properly make the effect of section enlargement and its transition into a page

cno6 test
Moderator Tag

Recommended Posts

Hello. Can anyone give advice on how to properly implement those animations presented on this site. https://mashroom.pro/ncracker/

I have three questions in particular:


1. How can I reduce the speed of the cards that fly from bottom to top of the scroll.
2. What are some approaches to properly implement a transition where a certain section is approached and becomes directly part of the screen, after which it scrolls freely and plays its animations. I have a problem that after the animation ends, the section jumps around (because I disable aspect-ratio and overflow: hidden).
3. Am I taking the right approach for animating product sections? I create a timeline for each section with a common scrolltrigger, in which I make a pin for the section, and then I add animations.

 

p.s. demo - 

See the Pen VwqWjNz by cno6 (@cno6) on CodePen

Link to comment
Share on other sites

It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or Stackblitz that demonstrates the issue? 

 

Please don't include your whole project. Just some colored <div> elements and the GSAP code is best. See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer.

 

Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

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

 

Using a framework/library like React, Vue, Next, etc.? 

CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import the gsap-trial NPM package for using any of the bonus plugins: 

 

Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. 

 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

  • Like 1
Link to comment
Share on other sites

  • cno6 changed the title to how to properly make the effect of section enlargement and its transition into a page

Hi,

 

9 hours ago, cno6 said:

1. How can I reduce the speed of the cards that fly from bottom to top of the scroll.

Just add more scroll space with the end point of your ScrollTriggers and give that animation a longer duration. More scroll space means more pixels have to be scrolled in order to complete the animation. A longer duration means that more of that scroll distance will be used for that particular animation:

const tl = gsap.timeline({
  scrollTrigger: {
    trigger: "#sect1",
    start: "0 0",
    end: "+=200%",
    scrub: true,
    pin: true
  }
});

const rects = document.querySelectorAll("#sect1 .wrapper");

tl.from(["#sect1 h2", "#sect1 .card"], { opacity: 0 }).fromTo(
  rects,
  { y: "100vh" },
  { y: "-100vh", duration: 1  }
);

The default duration of a GSAP instance is 0.5 seconds, so in this case we have an instance that is 0.5 seconds and another that is 1 second (double). The timeline is spread over 200%, that is twice the height of the viewport, so 67% of the scroll distance will scrub the first animation and 133% of the scroll will scrub the second, which makes it last longer.

 

This video made by @Cassie explains that in a visual way:

 

9 hours ago, cno6 said:

3. Am I taking the right approach for animating product sections? I create a timeline for each section with a common scrolltrigger, in which I make a pin for the section, and then I add animations.

If it works it works, right? Right now you have a clean, simple and easy to follow code that is doing what is supposed to, so in my book at least there is nothing that has to be changed there.

 

9 hours ago, cno6 said:

2. What are some approaches to properly implement a transition where a certain section is approached and becomes directly part of the screen, after which it scrolls freely and plays its animations. I have a problem that after the animation ends, the section jumps around (because I disable aspect-ratio and overflow: hidden).

Sorry but I don't follow what you mean with this. Please be more specific or create a new minimal demo that illustrates this behaviour only.

 

Hopefully this helps.

Happy Tweening!

  • Like 1
Link to comment
Share on other sites

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