HTML-Joysticks icon indicating copy to clipboard operation
HTML-Joysticks copied to clipboard

There is a bug with origin when we disable return to zero

Open 0x0fe opened this issue 2 years ago • 1 comments

Hi, I have disabled the return to zero on lift because i want the joystick to stay at the last position until next drag, to do so i just commented the following

 //transition the joystick position back to center
 //stick.style.transition = '.2s';
//stick.style.transform = `translate3d(0px, 0px, 0px)`;
 // reset everything
 //self.value = { x: 0, y: 0 };

While this solves the return to zero on lift it also brings an issue : on next drag the stick will return to zero by itself before it moves. This disturbs the usage but also creates an offset between the touch point and the stick and this offset is maintained until next lift, so essentially the stick is no longer under the mouse or finger anymore when i drag it.

i am not sure what causes this exactly, i suspect it is related to the distance/motion calculation but it is not clear what is wrong, if you have an idea, it is welcome.

I made jsfiddle that shows the problem: https://jsfiddle.net/wbyzq36t/ Thanks

0x0fe avatar Aug 17 '22 20:08 0x0fe

so, here is what appends, in the following log i moved the stick to right top corner, release and clic in it to drag, when i start to drag after lift the stick resets to center position before moving rather than starting from current position. image

0x0fe avatar Aug 17 '22 21:08 0x0fe