Jump to content
Search Community

Draggable and Inertia error: "Not tracking velocity of rotation"

alexb148 test
Moderator Tag

Recommended Posts

I'm using Draggable with the Inertia plugin to create a wheel that can be spun by the user. It's all working fine and does what I expect... until it doesn't.

 

Sometimes I spin, and just get the console error "Not tracking velocity of rotation." Searching hasn't yielded any info on what this error means.

 

There doesn't seem to be any pattern to when it doesn't work - it just sometimes doesn't, for whatever reason.

 

Is anyone able to shed any light on what could cause this error, or how I can debug it further? Thanks!

 

Screenshot2023-09-18at15_48_39.thumb.png.5a15bb9a9102388ff06be901d60cade0.png

Link to comment
Share on other sites

Hi,

 

Sorry to hear about the troubles, but there isn't a lot we can do without a minimal demo that reproduces the error you're seeing.

 

The only thing I can think of is that you're not using the latest version of GSAP, Draggable and Inertia or that you're using different versions.

 

Finally the issue seems to stem from something in your Spinner.js file, basically in the onDragEnd callback, but like I said without a demo, I'm basically  guessing blindly here.

 

Happy Tweening!

Link to comment
Share on other sites

Thanks - your message helped me figure out a silly mistake.

 

My onDragEnd function was simply:

 

const onDragEnd = (e) => {
  const velocity = InertiaPlugin.getVelocity(e.target, 'rotation');
}

 

The issue was that depending on where my swipe ended, e.target was not always the element with Draggable applied. Which explains the seemingly random nature of the issue.

  • Like 1
Link to comment
Share on other sites

Hi,

 

A solution is to use an anonymous function where this is the Draggable instance:

onDragEnd: function() {
  InertiaPlugin.getVelocity(this.target, "rotation");
}

Like that, regardless of where the pointer is when the Drag End event is called, the target will always be the Draggable's instance target.

 

Hopefully this helps.

Happy Tweening!

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