A Simple Discrete-Event Simulation: Part 85

Direct link for mobile devices.

Today I made the selection action work using touch events in addition to the mouse click event. The touch mechanism in JavaScript for mobile browsers does not current have a click counterpart so we have to simulate the action using the events we do have. I’ve done it in the most naive way, by simply activating the desired event if a touch event ends within a sufficiently short period of time. I’ve included the code below, with comments for what’s been added. This implementation was pretty mindless, consisting of about eight lines.

Interestingly, at least on my iPhone, this process continues to work without adjustment when the user zooms the screen in and out, indicating that the OS is handling that part of the scaling process natively. When zooming of the 2D image is handled separately, however, and again I haven’t gotten to this yet, the situation is going to get more complex and will need to be handled explicitly.

I’ve left stubs in for checking to see that we haven’t dragged anything too far, and have also stubbed in the ability to not start executing a drag until it’s clear the user really means it. This could all be tuned more over time but I imagine that a number of capabilities are going to be added over time and I want to get a better feel for what the fuller list might include before doing the final polish on any one feature.

This entry was posted in Software and tagged , , , , . Bookmark the permalink.

Leave a Reply