Jump to content
Search Community

How to scale an element's size up and down - Scroll trigger

purple-lightsaber test
Moderator Tag

Recommended Posts

I'd like to copy this site's hero, the video expands but I'd also like it to scale down in size right after.

https://www.basedesign.com/

 

I've got the GSAP code working for the scaling up, but how do you add the scale down scroll trigger after the first one is complete?

$(".sticky-circle_wrap").each(function (index) {
  let triggerElement = $(this);
  let targetElement = $(".sticky-circle_element");

  let tl = gsap.timeline({
    scrollTrigger: {
      trigger: triggerElement,
      // trigger element - viewport
      start: "top top",
      end: "bottom bottom",
      scrub: 1
    }
  });
  tl.fromTo(
    targetElement,
    {
            scale: 0.35,
      opacity: 0.40,
    },
    {
            scale: 0.75,
      opacity: 1,
      duration: 1
    }
  );

});

 

Link to comment
Share on other sites

Hey there!

 

Timeline's allow you to sequence animations, so you can just add another tween after the first one. By default they'll play back to back.

Something like this?
 

tl.fromTo(targetElement,{
  scale: 0.35,
  opacity: 0.40,
},{
  scale: 0.75,
  opacity: 1,
  duration: 1
})
.to(targetElement,{
  scale: 0.35,
  opacity: 0.40,
});


Hope this helps.

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