Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
AsKadir

Can't get velocity onDrag properly, have an error

Go to solution Solved by GreenSock,

Recommended Posts

Hey all,

I have a simple draggable horizontal div with images, I'm trying to get velocity of inertia onDrag,

I can't understand what's the problem, I get an error tracker.get is not a function

 

What am I doing wrong? Can you help me, please?

Thanks in advance!

See the Pen dypBQyR by ChicagoJostik (@ChicagoJostik) on CodePen

Link to comment
Share on other sites

  • Solution

That's just because the track() method returns an Array of trackers (because you might pass selector text as the target, for example, so there could be a bunch of trackers - one for each element). In your case, it should be as simple as: 

// BAD
let tracker = InertiaPlugin.track(holder, "x");

// GOOD
let tracker = InertiaPlugin.track(holder, "x")[0];

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 4 weeks later...

Might want to add this info to the InertiaPlugin docs, as they currently contain only the "bad" example.

Link to comment
Share on other sites

47 minutes ago, billyZduke said:

Might want to add this info to the InertiaPlugin docs, as they currently contain only the "bad" example.

@billyZduke would you mind providing more details about where you found those? I can't seem to find any but I must be missing something obvious. 

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