question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not possible to move with interactive objects ( while function contains stopPropagation() )

See original GitHub issue

Expected Behavior

Event pointermove correctly fired on all interactive objects even when function contains event.stopPropagation().

Current Behavior

I added two interactive sprites included their interactive functions pointerdown, pointermove, pointerup and pointerupoutside. In each of interactive function I fire event.stopPropagation().

In this use case is pointermove fired only at last sprite.

Check example: https://www.pixiplayground.com/#/edit/m0MxjDUGhTiZ5KU5aRO2C ( you should try move with both sprites, one is not working for me )

Environment

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
lainocommented, Sep 4, 2019

This is more fun with event re-use.

The reason it’s “weird” here is pretty much because this line is “missing”:

app.renderer.plugins.interaction.moveWhenInside = true;

Because of that both bunnies get the mousemove event, but the first bunny event listener stops the propagation of it, so it can’t really reach the second bunny.

Now don’t go adding that line just yet, because with it it’s easy to “lose” a bunny while dragging (feel free to try this to find out what I’m talking about.)

Instead only use .stopPropagation when you actually “consumed” the event:

function pointermove(e) {
    console.log(`[${this.name}] [${e.type}] [dragging=${this.dragging}]`)
    if (this.dragging) {
        e.stopPropagation();
        // ...
    }
}

To really “fix” all this weirdness, InteractionManager would need to stop re-using events like that and also set:

app.renderer.plugins.interaction.moveWhenInside = true;

by default. Because not only is that a performance killer, (we’re dispatching move events to everything), it’s also confusing as hell. On top of that maybe provide a guide on how to do dragging properly: which is to listen to move events on a parent container, not the thing itself.

2reactions
eXponentacommented, Sep 4, 2019

@laino I rewrited @themoonrat 's fiddle too. Sometimes i forgets clone it. It’s time to fix the playground.I created issues about auto clone: https://github.com/englercj/playground/issues/10

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not possible to move with interactive objects ( while function ...
Expected Behavior Event pointermove correctly fired on all interactive objects even when function contains event.stopPropagation().
Read more >
stopPropagation vs. stopImmediatePropagation - Stack Overflow
e.stopImmediatePropagation() stops any further handler from being called for this event, no exceptions · e.stopPropagation() is similar, but does still call all ...
Read more >
Event.stopPropagation() - Web APIs | MDN
The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
Read more >
event.stopPropagation() in a modular system - Moxio
If you event.stopPropagation() in the click listener of the checkbox in the bubbling phase the event will no longer bubble up and it...
Read more >
A simplified explanation of event propagation in JavaScript.
That e.stopPropagation() halts this “bubbling” of events “up” through the DOM. We stop all of the other events in the stack. Awesome!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found