Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple phone draggables at the same time #128

Closed
agnitos opened this issue Dec 11, 2018 · 1 comment · Fixed by #133
Closed

Multiple phone draggables at the same time #128

agnitos opened this issue Dec 11, 2018 · 1 comment · Fixed by #133
Labels

Comments

@agnitos
Copy link
Contributor

agnitos commented Dec 11, 2018

At the moment if you drag multiple draggables at the same time on phone they stack on top of each other. The reason is that if multiple touch move event happen in the same frame, then they all are pushed in TouchList array and they are accessible to each touchmove event. The problem is in position model, fromEvent function, the coordinates are always from the 1st element in the array:

return new Position(e.changedTouches[0].clientX, e.changedTouches[0].clientY);

So the 2nd draggable sets its position to 1st draggable position and they overlap, the solution can be to check if the target is correct, something like this:

for (let i = 0; i < e.changedTouches.length; i++) {
  if (e.changedTouches[i].target === e.target) {
    return new Position(e.changedTouches[i].clientX, e.changedTouches[i].clientY);
  }
}
return new Position(0, 0); // I don't know if this can happen
@xieziyu
Copy link
Owner

xieziyu commented Dec 16, 2018

Thanks for reporting this issue.

@xieziyu xieziyu added the bug label Dec 22, 2018
xieziyu pushed a commit that referenced this issue Dec 22, 2018
@xieziyu xieziyu mentioned this issue Dec 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants