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 6695587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:14:23+00:00 2026-05-26T06:14:23+00:00

I have a drag UI I’m creating, and I need to be able to

  • 0

I have a drag UI I’m creating, and I need to be able to disable anchor tags following an HREF if the user clicks on an anchor tag, but then drags more than 25 PX. The drag sensor I have working, the problem is I cannot use .click() because the mousedown has already fired for the drag, and .mouseup() seems to be too late to the game, because the event is still firing.

How do I make the following code right?

$(document).mousemove(function (e) {
  distance = e.pageX - initialPosition;
  $('#panorama').css({ 'left': distance });
  if (Math.abs(distance - 0) > 25) {
    //Event in question below:
    $('a').mouseup(function (e) { e.preventDefault(); });
  }
  return false;
});
  • 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-26T06:14:23+00:00Added an answer on May 26, 2026 at 6:14 am

    It’s hard to know what you are actually intending, but the moving to an anchor’s destination occurs in the click event, not the mouseup event, so you’ll need to handle the cancel there.

    You’ll also probably want to do the distance calculation in a click event, also, instead of waiting to register the handler until that threshold is passed, but that’s your call.

    You can view code that seems to deal with your situation here: jsFiddle

    A lot of the code is to visualize the coordinates and the order of event triggers.

    For posterity:

    HTML

    <a href="404.html">Link.....................................</a>
    X:<span id='mouseX'></span>
    Y:<span id='mouseY'></span>
    

    JS

    var initialPos = 0;
    
    $('a').mousedown(function(e){
      updatePos(e);
      console.log('down');
      initialPos = e.pageX;
    });
    $('a').mousemove(function(e){
      console.log('move');
      updatePos(e);
    });
    $('a').click(function(e){
      console.log('click');
      updatePos(e);
      var distance = e.pageX - initialPos;
      if (Math.abs(distance) > 5) {
        console.log("Passed threshold, cancelling event");
        e.preventDefault();
        return false;
      }
    });
    
    function updatePos(e) {
      $('#mouseX').html(e.pageX);
      $('#mouseY').html(e.pageY);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a User Control in C#.Net 2.0. I have to apply drag
I have a container that contains an image that I need to drag from
I have a datagrid which is populated with CSV data when the user drag/drops
I have implemented drag and drop in my application, but am having some difficulty
I'm new to flash, but I have drag and drop code for my movieclips
I have to drag and i am not able to drag it perfectly: The
I have a drag and drop handler in my Flex application. The drag proxy,
I have created a nested list with drag/drop functionality. My issue is that I
i have a div i want to drag confined in a particular container. i
i have a treview control with drag&drop functionality that response to draw the node

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.