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

Fixed a bug where some touch events still performed the default actions. #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stretchtiberius
Copy link

Fixed a bug where some touch events still performed the default actions. Also, added code to remove the last touch-point visualization after the touchend event.

…ns. Also, added code to remove the last touch-point visualization after the touchend event.
@borismus
Copy link
Owner

Thanks but I don't think your touchend modification is right. You can't clear the list of touches every time there's a touchend because there may be other fingers on the screen... I'm seeing a flickering effect.

canvas.addEventListener('touchend', function() {
event.preventDefault();
ctx.clearRect(0, 0, w, h);
touches = [];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this line to:
touches = event.touches;

@stretchtiberius
Copy link
Author

I see what you are saying. You are correct. It is interesting that I did not see the flickering myself. Perhaps, change the line in the touchend listener:
-touches = [];
+touches = event.touches;

The most important change I made was to add:
event.preventDefault();
on all the listeners. The code did not work otherwise.

I should also mention that I am testing this on an actual touchscreen with the MagicTouch script.

@borismus
Copy link
Owner

The point of MagicTouch is to simulate a touch screen when you don't have access to one, though. Not sure that your use case is a valid one, unless I'm misunderstanding something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants