Jump to content
Search Community

Can't rewrite infinite carousel from gsap v2 to gsap v3

AsKadir test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

Hi,

 

The value passed to the modifiers plugin is actually a string and has px at the end, so basically the method is returning NaN. This seems to work:

function animateCarousel(delta) {
  gsap.to(boxes, {
    duration: boxes.length * 0.5,
    x: function(i, target) {
      var x = Math.round(gsap.getProperty(target, "x")) + wrapWidth * delta;
      return x;
    },
    ease: "none",
    modifiers: {
      x: function(x) {
        return wrap(parseFloat(x), -boxWidth, wrapWidth)
      }
    },
    repeat: -1
  });
}

function wrap(value, min, max) {
  var v = value - min;
  var r = max - min;
  return ((r + v % r) % r) + min + "px";
}

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