Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7493091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:45:08+00:00 2026-05-29T16:45:08+00:00

I am trying to capture the duration elapsed between touch start and end, and

  • 0

I am trying to capture the duration elapsed between touch start and end, and cant seem to get a consistent behavior no matter what I try.

I have tried a few different solutions, but the behavior is always sporadic. Here is an example of what I am currently trying(below).

I have alerts in place for the long and short touch, but there just seems to be no consistency in the result.

I do see a similar question has been asked here before ‘get-the-duration-of-a-touch-in-javascript’ but that solution produces the same uncertain results.

Any advise would be really appreciated.

$(document).ready(function() {
    var $IndividualItem = $(".wrapperWithHover li a");
    var touchStartTime;
    var touchStartLocation;
    var touchEndTime;
    var touchEndLocation;
    $IndividualItem.bind('touchstart', startOfTouch);
    $IndividualItem.bind('touchend', endOfTouch);
    $IndividualItem.bind('touchmove', endOfTouch);


 function startOfTouch(e) {
     e.preventDefault();
     var d = new Date();
     touchStartTime = d.getTime();

}
function endOfTouch(e) {
    e.preventDefault();
     var d = new Date();
     touchEndTime= d.getTime();
     doTouchLogic();
}

function doTouchLogic() {
     var duration = touchEndTime - touchStartTime;
     if (duration <= 1500) {
         alert('1');
               }
     if (duration > 1500) {
          alert('2');
     }       
    duration = null;

}






$('.wrapperWithHover li a').each(function() {

   var timeout,
       longtouch;

   $(this).bind('touchstart', function() {
      timeout = setTimeout(function() {
          longtouch = true;
      }, 1000);
   }).bind('touchend', function() {
       if (longtouch) {
          // It was a long touch.
       }
       longtouch = false;
       clearTimeout(timeout);
   });

});

});

here is a small snip of html I’m using for testing.(had to remove the a hrefs as stackoverflow prevented me from submitting the question with them there.)

  • test
  • test
  • test
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:45:12+00:00Added an answer on May 29, 2026 at 4:45 pm

    You don’t have to capture the touchmove event. Because of that endOfTouch method is called on touchmove event before even touchend has happened.

    Remove this line from your code and try. It should give you proper result.

    $IndividualItem.bind('touchmove', endOfTouch);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do an image capture on a high end Nokia phone (N95).
I trying to capture packets using SharpPcap library. I'm able to return the packets
I am trying to capture output from an install script (that uses scp) and
I'm trying to capture the ENTER event of a TextInput like so: a_txt.addEventListener(fl.events.ComponentEvent.ENTER, aEnter);
I am trying to capture urls in an html page that is being repeated
I'm trying to capture packets from two devices on my network. I have tcpdump
I'm trying to capture the Tab key in a Windows Forms application and do
I have an application in which I'm trying to capture the shift key modifier
I have a test list that I am trying to capture data from using
I have a slight problem, I am trying to capture the input of two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.