Jump to content
Search Community

SeamlessLoop helper function revered doesnt work

Levin Riegner test
Moderator Tag

Recommended Posts

Hey, a quick one. When using the HorizontalLoop / SeamlessLoop (https://gsap.com/docs/v3/HelperFunctions/helpers/seamlessLoop) helper function, the reversed option doesnt change anything.

 

My example code:
 

// ... React useEffect code surrounding this.
const logos = logoRefs.map((ref) => ref.current);

const loop = horizontalLoop(logos, {
  reversed: true, // Doesnt work
  speed: 1, // Works
  paused: false, // Works
  repeat: -1, // Works
});

const performanceTimeline = gsap.timeline({
  scrollTrigger: {
    trigger: main.current,
    start: 'top bottom',
    end: 'bottom top',
    scrub: true,
    onEnter: () => loop.play(),
    onLeave: () => loop.pause(),
    onEnterBack: () => loop.play(),
    onLeaveBack: () => loop.pause(),
  },
});

 

Im expecting my marquee to animate to the right vs to the left which its currently doing.

 

 

 

As im writing this it turns out the timeline causing the reverse to not work - specifically the onEnter etc.Why is this effecting the ability to reverse? Im pausing for performance reasons (offscreen = paused, onScreen = play)

Link to comment
Share on other sites

Hi,

 

The issue is that the GSAP Timeline returned by the Seamless Loop helper is reversed when you set reversed: true in the config object. Then when you do this:

onEnter: () => loop.play(),

The play method sets the timeline's reversed state to false, so is now going forward, instead of using loop.play() use loop.reverse().

 

Here is a simple demo:

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

 

Hopefully this helps.

Happy Tweening!

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