Tween.js speeds up when triggered by touch but not by mouse

What is happening is that I’m moving an object back and forth using a button trigger and the movement is handled by the tween.js script. It works perfectly when triggered by the mouse. But when triggered by either an iPad or Android touch device, the speed of movement gets progressively faster with each cycle of pressing the buttons that trigger the movement.

I can’t post an example at this time, so I’m just casting this question out in the hope that I can get pointed in the right direction of a likely good place to look. I’ve already scanned through tween.js to see if anything seems related and nothing jumped out at me. I searched the forums and saw nothing suggesting that this is a generally known issue, but maybe someone has tripped over something similar? I understand answers are limited without me being able to show the specific project/scripts involved.

Thanks!

I’m not sure why this speed up problem does not show itself on simpler projects that are configured the same as the more complex project where I had this problem, but the resolution (for now) has been to turn off the “touch” functionality for the buttons that fire the tweens. It seems that most (all?) tablets will fire a “mouse down” event as well as a touch event. The easy solution for now is to not listen for “touch” events on the buttons.

So the tween doesn’t appear to be the culprit. Firing the same tween nearly or actually simultaneously creates a situation where each subsequent tween is operated at a faster and faster speed.

How odd. Maybe there is some weird double callback on touch events?

This forum post is part of what got me on that track.


That user solved his problem using preventDefault(), That may be a better way to resolve it. Unfortunately I was unable to get that to work for me and have bigger fish to fry. But this is something I’d like to visit later and understand better. Since I am Windows based, troubleshooting on an iPad is a real problem. Getting a console to monitor seems almost impossible without also having a Mac.

Is it only the apple device giving this problem? Does this happen on Android?

Yes. It behaves the same on my Motorola G5+ as well.

If that’s the case, you can try two things to debug it:

image

Looks great. That could be super useful when the issue appears on both platforms. I’m up to my ears in other stuff right now, but I’ll try to take a look at this maybe this weekend.

Thanks!