With a double click detector, you will need to delay firing the single click
event before you are sure the double click will not happen.


On Wed, Jun 22, 2011 at 2:32 PM, Brandon <[email protected]> wrote:

> I'm trying to create a custom double tap event to be used on mobile/
> touch devices. I'm using CPojer's PowerTools plugin and I've taken a
> look at how he created the Touch, Swipe, etc. events and tried to roll
> my own based on those. I have it working to a degree but I know this
> can be done better. One example of a problem I've run into is without
> also assigning a 'click' event, or touch equivalent, the default event
> occurs.
>
> For Example:
>
> <a href="http://www.google.com"; id="test_1">Hello!</a>
>
> <script>
> window.addEvent( 'domready', function() {
>        $( 'test_1' ).addEvent( 'doubletap', function( event ) {
>                console.log( 'double click!' );
>                event.stop();
>        });
> });
> </script>
>
> So without adding in a click handler and stopping the event, we shoot
> off to www.google.com. If there is no href attribute on that link my
> double tap event fires correctly. Ugh.
>
> I've added my working code to JSFiddle (http://jsfiddle.net/E5DmB/
> 13/ <http://jsfiddle.net/E5DmB/%0A13/>). This is my first dive into
> creating any sort of custom event and
> I'm in need of assistance and would love some ideas or guidance on how
> to get this done properly.

Reply via email to