Jump to content
Search Community

Scroll horizontally and scroll Start from Center.

ann1640 test
Moderator Tag

Recommended Posts

Hi,

 

You could create a timeline and animate the entire container first and then the sections:

let sections = gsap.utils.toArray(".container .panel");

gsap.set(".container", {
  x: () => ((window.innerWidth / 2) - sections[0].clientWidth / 2)
});

gsap.timeline({
  scrollTrigger: {
    trigger: ".side-scrolling-wrapper",
    start: "top top",
    markers: true,
    scrub: 0.5,
    snap: 0.1,
    end: () => "+=" + document.querySelector(".container").offsetWidth
  }
})
.to(".container", {
  x: 0,
  duration: 0.5 / sections.length,
  ease: "none",
})
.to(sections, {
  xPercent: -180 * (sections.length - 1),
  ease: "none",
  opacity: 1,
});

Here is a fork of your codepen:

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

 

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