doubleTap.js

This utility emulates click and dblclick for touch devices on typically non-clickable elements (e.g. an ordinary <div>).

Unfortunately, touch browsers fire a broken 'click' event which does not update the number of clicks making double click events much more difficult handle. As such two new events are needed which gets consistently fired in both environments. These are implemented here as 'tap' and 'dbltap'.

The first example fires no new tap events, but it monitors native click events. With this example, you can see the brokenness of clicks on touch.

native click and dblclick

The second example fires both tap and dbltap:

both tap and dbltap

The third example fires both tap and dbltap, but the handler only allows one or the other to fire for a particular series. Single clicks are therefore delayed until a double click is impossible:

either tap or dbltap, but not both