Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Fast Click - Click vs TouchStart
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tom Krones  
View profile  
 More options Oct 5 2010, 10:42 am
From: Tom Krones <tkro...@gmail.com>
Date: Tue, 5 Oct 2010 07:42:35 -0700 (PDT)
Local: Tues, Oct 5 2010 10:42 am
Subject: Fast Click - Click vs TouchStart
Hello,

I found when playing with my app that the iPhone puts a delay on the
Click event which makes the app feel sluggish.  I also wanted an
onclick highlight or active feature added to my app so the user knows
they clicked.

I wrote the code below.  I use XUI and just added this code right
below the definition of the fire event (for me, around line 500).  Now
instead of calling
x$('#elementID').click(callback);
i use
x$('#elementID').fastClick(callback);
it applies the 'highlight' class to the element which gives the user
feed back that they've clicked the element.

This code has a bug though, when scrolling on a touch screen, if your
swipe starts by landing on an element with the fastClick event the
'highlight' class is applied to that element for a brief moment which
I don't like.  Anyone see how I might be able to prevent that?

What have you guys done to fix the click delay problem and get an
active or highlight feature?  Did I waist my time, is thier something
already written to handle this?

fastClick: function (fn) {
        return this.each(function (el) {
                xui(this).touchstart(function (e) {
                        this.moved = false;
                        x$(this).addClass('highlight');

                        x$(this).touchmove(function (e) {
                                if (!this.moved) {
                                        x$(this).removeClass('highlight');
                                }
                                this.moved = true;
                        }).touchend(function (e) {
                                x$(this).un('touchmove');
                                x$(this).un('touchend');
                                x$(this).removeClass('highlight');

                                if (!this.moved) {
                                        fn();
                                        e.preventDefault();
                                }
                        });
                });
        });


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Giacomo Balli  
View profile  
 More options Oct 5 2010, 12:43 pm
From: Giacomo Balli <giacomoba...@gmail.com>
Date: Tue, 5 Oct 2010 09:43:53 -0700 (PDT)
Local: Tues, Oct 5 2010 12:43 pm
Subject: Re: Fast Click - Click vs TouchStart
use ontouchend

On Oct 5, 4:42 pm, Tom Krones <tkro...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Krones  
View profile  
 More options Oct 5 2010, 12:58 pm
From: Tom Krones <tkro...@gmail.com>
Date: Tue, 5 Oct 2010 09:58:10 -0700
Local: Tues, Oct 5 2010 12:58 pm
Subject: Re: [PhoneGap] Re: Fast Click - Click vs TouchStart

So you're saying do something like this?

fastClick: function (fn) {
    return this.each(function (el) {
        xui(this).touchend(function (e) {
            fn();
            e.preventDefault();
        });
    });

}

That's much simpler and works well but how do I get the highlight feature?

Thanks,
Tom

On Tue, Oct 5, 2010 at 9:43 AM, Giacomo Balli <giacomoba...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Krones  
View profile  
 More options Oct 5 2010, 12:59 pm
From: Tom Krones <tkro...@gmail.com>
Date: Tue, 5 Oct 2010 09:59:06 -0700
Local: Tues, Oct 5 2010 12:59 pm
Subject: Re: Fast Click - Click vs TouchStart

Another bug that I've found is that touchstart/touchend doesn't work on
computers with mice, only on touch screens which makes the app no longer
usable when browsing/debugging on a computer.  Any ideas on how I might
check if touchstart or touchend are valid events and if not use click?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Giacomo Balli  
View profile   Translate to Translated (View Original)
 More options Oct 5 2010, 1:00 pm
From: Giacomo Balli <giacomoba...@gmail.com>
Date: Tue, 5 Oct 2010 19:00:19 +0200
Local: Tues, Oct 5 2010 1:00 pm
Subject: Re: [PhoneGap] Re: Fast Click - Click vs TouchStart

css property ":active" might also work with ontouchend don't remember...

On Oct 5, 2010, at 6:58 PM, Tom Krones wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jesse  
View profile  
 More options Oct 5 2010, 1:36 pm
From: Jesse <jesse.macfad...@nitobi.com>
Date: Tue, 5 Oct 2010 10:36:24 -0700
Local: Tues, Oct 5 2010 1:36 pm
Subject: Re: [PhoneGap] Re: Fast Click - Click vs TouchStart

var CanTouch = (("createTouch" in document) || ("TouchEvent" in window));

Sent from my iPhone

On 2010-10-05, at 10:00 AM, Giacomo Balli <giacomoba...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Krones  
View profile  
 More options Oct 5 2010, 2:08 pm
From: Tom Krones <tkro...@gmail.com>
Date: Tue, 5 Oct 2010 11:08:32 -0700
Local: Tues, Oct 5 2010 2:08 pm
Subject: Re: [PhoneGap] Re: Fast Click - Click vs TouchStart

Cool thanks.  I started to use your code then noticed that xui actually has
something built in to determine if the device can handle touches.

xui.touch


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Krones  
View profile  
 More options Oct 5 2010, 2:12 pm
From: Tom Krones <tkro...@gmail.com>
Date: Tue, 5 Oct 2010 11:12:35 -0700
Local: Tues, Oct 5 2010 2:12 pm
Subject: Re: [PhoneGap] Re: Fast Click - Click vs TouchStart

With the code below, when scrolling on a touch screen, if your swipe starts
by landing on an element with the fastClick event the event fires even
though you were just trying to scroll the page...

Any ideas?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Giacomo Balli  
View profile  
 More options Oct 5 2010, 6:10 pm
From: Giacomo Balli <giacomoba...@gmail.com>
Date: Tue, 5 Oct 2010 15:10:15 -0700 (PDT)
Local: Tues, Oct 5 2010 6:10 pm
Subject: Re: Fast Click - Click vs TouchStart
i guess accounting for clumsy users is the hardest part of
coding... ;)

On Oct 5, 8:12 pm, Tom Krones <tkro...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Will Bowling  
View profile  
 More options Sep 28 2012, 3:45 pm
From: Will Bowling <tiltedcir...@gmail.com>
Date: Fri, 28 Sep 2012 12:45:21 -0700 (PDT)
Local: Fri, Sep 28 2012 3:45 pm
Subject: Re: Fast Click - Click vs TouchStart

I believe this is the solution to keep the user from accidentally calling
the function. Please note, my syntax may be off. ;)

*fastClick: function (fn) {*
*    return this.each(function (el) {*
*        
$(this).touchstart(function(){e.preventDefault();}).touchend(function (e) {*
*            fn();*
*            e.preventDefault();*
*        });*
*    });*
*}*


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »