Jump to content

How come when we add a mousemove handler to an element, the handler gets fired when we are moving around the whole canvas?


mohammad-ahmadi
 Share

Recommended Posts

Here's the thing:

If I create a sprite or graphics, and add a mousemove handler for it, then what I expected to happen was that whenever I move my mouse over that element, that handler gets fired, but that's not what's happening, and that handler gets fired when you move the mouse over the entire canvas, why is that?

var el = new PIXI.Graphics();
el.interactive = true;
el.buttonMode = true;
el.beginFill(0x00FFFF, 1);
el.lineStyle(4, 0xFF0000, 1);
el.drawRect(0, 0, 100, 100);
el.endFill();
el
    .on('mousemove', move)
    .on('touchmove', move);
stage.addChild(el)

function move() {
    console.log('mousemove on this element?');
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...