Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The mousemove event is always executed #1250

Closed
fbrussa opened this issue Dec 4, 2014 · 6 comments
Closed

The mousemove event is always executed #1250

fbrussa opened this issue Dec 4, 2014 · 6 comments

Comments

@fbrussa
Copy link

fbrussa commented Dec 4, 2014

Hi, in this sample look at the console

http://jsfiddle.net/fv08nsxo/

The "mousemove " event is triggered always.
This should be only when the mouse is over the DisplayObjectContainer or I have a misconception?

@Cristy94
Copy link
Contributor

Cristy94 commented Dec 4, 2014

Are you sure you sent the right fiddle? This one has nothing related to mouse events.

@fbrussa
Copy link
Author

fbrussa commented Dec 4, 2014

sorry, here is fixed

http://jsfiddle.net/fv08nsxo/1/

@Cristy94
Copy link
Contributor

Cristy94 commented Dec 4, 2014

I do not know if this is expected behavior.
Here is an example where this could be useful: you have a smiley face with eyes following the mouse. Even if the mouse is not over the face it still tracks the mouse with its eyes. Now, I personally think that this is not the way to solve this problem, you should place a larger container in which to track the mouse movements and based on those movements set the eyes position.

So, I think this should be fixed mostly because all the other events only trigger when the mouse is over that element. Why would mousemove be different?

Here is a quick fix, update PIXI interaction mousemove function:

for (var i = 0; i < length; i++)
{
    var item = this.interactiveItems[i];

    // Call the function!
    if (item.mousemove)
    {
        item.mousemove(this.mouse);
    }
}

To

for (var i = 0; i < length; i++)
{
    var item = this.interactiveItems[i];

    item.__hit = this.hitTest(item, this.mouse);
    // Call the function!
    if (item.mousemove && item.__hit)
    {
        item.mousemove(this.mouse);
    }
}

Demo: http://jsfiddle.net/fv08nsxo/2/

Does it make sense to have this change as a PR?

@NikkiKoole
Copy link
Contributor

I use that feature quite regularly when dragging items.
To get around your issue you could do a box.isOver = true in a mouseover and box.isOver = false in a mouseout, then in your mousemove you can just return early when box.isOver === false

@GoodBoyDigital
Copy link
Member

hi guys,
This is actually intended behavior. As @NikkiKoole mentioned its very handy to have it set up like this. It is also quite easy to impose the restriction at your application level if required. Cheers!

@lock
Copy link

lock bot commented Feb 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants