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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:49:32+00:00 2026-05-23T15:49:32+00:00

I am trying to debug an event handling bug in a complicated web application,

  • 0

I am trying to debug an event handling bug in a complicated web application, but I’ve reduced the problem to a simple example that demonstrates the behaviour that I’m confused by.

My example page, based one of the Raphaël examples, is as follows:

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Raphaël · Drag-n-drop Example</title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script src="http://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"></script>
        <script>
            window.onload = function () {
                $('body').mousemove(function(e) {
                    // console.log("in body's mousemove");
                    // Uncommenting the next line stops the move
                    // function below from being called:
                    // e.stopPropagation();
                });
                var R = Raphael(0, 0, "100%", "100%");
                var r = R.circle(100, 100, 50).attr({fill: "hsb(0, 1, 1)", stroke: "none", opacity: .5});
                var start = function () {
                    this.ox = this.attr("cx");
                    this.oy = this.attr("cy");
                    this.animate({r: 70, opacity: .25}, 500, ">");
                },
                move = function (dx, dy) {
                    // console.log("in move function for the circle", this);
                    this.attr({cx: this.ox + dx, cy: this.oy + dy});
                },
                up = function () {
                    this.animate({r: 50, opacity: .5}, 500, ">");
                };
                r.drag(move, start, up);
            };
        </script>
    </head>
    <body>
        <div id="holder"></div>
    </body>
</html>

That version works as expected — you can drag the red circle around — but uncommenting the e.stopPropagation() line breaks dragging. If you have Firebug or Chrome and uncomment the console.log lines, you can see that the move function is never called – somehow the mousemove handler for the body element is being called before the event gets to the circle’s handler.

I don’t understand how this can be, since the mousemove hander on the body element is set in the bubble phase of event handling. If I understand the order in which events are processed correctly, the order in which mousemove handlers would be called here is approximately:

  1. capture phase: the body element’s mousemove (null)
  2. capture phase: the svg element’s mousemove (null)
  3. capture phase: the circle’s mousemove (null)
  4. bubble phase: the circle’s mousemove (set by Raphaël when dragging starts, and which calls the move function)
  5. bubble phase: the svg element’s mousemove (null)
  6. bubble phase: the body element’s mousemove (set as above, and which stops propagation)

If that’s right, I don’t understand how stopping propagation of the event in the mousemove handler of body in the bubble phase could break dragging, since it should happen after the circle has dealt with the event.

It would be great if someone could explain what’s going on in this example, and in particular whether I’ve misunderstood how the event handling works, or there’s something peculiar about how Raphaël implements dragging.

  • 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-23T15:49:33+00:00Added an answer on May 23, 2026 at 3:49 pm

    I tried asking about this on the Raphaël mailing list, and the replies there explain that the Raphaël mousemove handler is actually attached to document, which explains the behaviour I was seeing. One of the replies also explains why dragging needs to be implemented like that:

    • http://groups.google.com/group/raphaeljs/t/4199e3e77c21bf5e
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to debug an ASP.NET web application in this environment: Windows Server Standard
When trying to debug a web application configured to use IIS Express 7.5 in
I am trying to debug a System.Web.HttpException that I keep getting. It could be
I am trying to use the Event Log to write some debug information and
I'm trying to debug a deadlock in a multi-threaded Python application after it has
I'm trying to debug an application (under PostgreSQL) and came across the following error:
I am trying to debug a strange issue with users that have LogMeIn installed.
I’m trying to debug a memory leak problem. I’m using mtrace() to get a
I have been trying to execute a button event in html page that displays
I am having a nightmare trying to debug the event receiver of a Sharepoint

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.