Jump to content
Search Community

InertiaPlugin.track returns Array?

joris-rotteveel test
Moderator Tag

Recommended Posts

Hi,

 

I just bought a subscription to GSAP in order to use the InertiaPlugin. Unfortunately I am running into issues with the track function

 

var tracker = InertiaPlugin.track(slider, 'x');
const vel = tracker.getVelocity('x');

The function track seems to be returning an Array and not a VelocityTracker object? I've created a codepen that demonstrates what I mean.

Can someone point out what the correct  way is to grab the velocity using the InertiaPlugin please?

See the Pen YzPbJxw?editors=1111 by joris-rotteveel (@joris-rotteveel) on CodePen

Link to comment
Share on other sites

Thanks for pointing that out, @joris-rotteveel. I just updated that function in the docs. Sorry about any confusion there. 

 

The reason it returns an Array is because you could pass selector text as the "target" that results in multiple targets, like:

var trackers = InertiaPlugin.track(".class", "x,y"); // returns an array with one VelocityTracker per .class element.

console.log(trackers.length); // however many ".class" elements there are. 

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