dmko Posted June 22, 2017 Share Posted June 22, 2017 Is there a way to get children to do something when they've been removed indirectly? Here's a jsbin to show what I mean - only the parent notifies when its been removed, but I'd like the child to notify as well: https://jsbin.com/lolicamohi/edit?js,console,output Quote Link to comment Share on other sites More sharing options...
Vitalije Posted June 22, 2017 Share Posted June 22, 2017 You should change handler function in parent, so that when removed it removes its children. parent.once('removed', function(){ console.log('parent removed'); parent.removeChild(child); // or if you want to make it more universal // parent.children.slice().forEach(function(c){ // parent.removeChild(c)}); }); https://jsbin.com/xusocineku/edit?js,console,output Quote Link to comment Share on other sites More sharing options...
dmko Posted June 22, 2017 Author Share Posted June 22, 2017 Yeah - that technically works in this small example, but in general is there no way for a DisplayObject to detect when it's been removed from the scene graph unless it was explicitly from a removeChild()? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 22, 2017 Share Posted June 22, 2017 Yes, there's no way. But i'm making pixijs v5 fork, again, and it has "removed from stage" event, so I'm concerned too dmko 1 Quote Link to comment Share on other sites More sharing options...
dmko Posted June 22, 2017 Author Share Posted June 22, 2017 Pixi v5 has everything I need!!! Quote Link to comment Share on other sites More sharing options...
Vitalije Posted June 22, 2017 Share Posted June 22, 2017 Technically you didn't remove child. It is still child of its parent. It would be confusing if child reports that it has been removed while still being proper child of its original parent. Quote Link to comment Share on other sites More sharing options...
dmko Posted June 22, 2017 Author Share Posted June 22, 2017 Depends on what we mean by "removed"... conceptually it could mean "removed from parent" OR "removed from scene" I agree that there should be different events for each of those Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 22, 2017 Share Posted June 22, 2017 26 minutes ago, dmko said: Pixi v5 has everything I need!!! I'll make multiple PR's for v5 version, but any of them can be simply rejected by the team. But everything will remain in my own fork that I publish soon Quote Link to comment Share on other sites More sharing options...
dmko Posted June 22, 2017 Author Share Posted June 22, 2017 hrm I'm a little worried about using a different fork... I kinda just want to `npm install pixi` and be off to the races... I hope your features make it in! Pixi 5 is a ways away though, no? it's still alpha? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 22, 2017 Share Posted June 22, 2017 Dont underestimate forks some people are using my alternative v4 in production: https://gameofbombs.github.io/pixi-bin/index.html?s=flip&f=cards.js&title=Cards Yeah, there are many broken things in v5, its definitely not for production. dmko 1 Quote Link to comment Share on other sites More sharing options...
Aymeric Posted April 24, 2020 Share Posted April 24, 2020 Hey, any news on this? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 24, 2020 Share Posted April 24, 2020 Nope, you have to do it yourself. My Stage PR wasnt merged back then, and too few expressed opinion that THEY NEED THIS THING. Quote Link to comment Share on other sites More sharing options...
Aymeric Posted April 25, 2020 Share Posted April 25, 2020 Wow coming from Flash background hard to believe it isn't added, very useful feature to detect object removed from scene and so kill their listeners etc :( Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 25, 2020 Share Posted April 25, 2020 I made it several times in my projects, including my own flash API, its just I do not have enough time and enough motivation from people to make it into pixi plugin. Here what was rejected in pixijs : https://github.com/pixijs/pixi.js/pull/4586 Yes, maybe in a month or two i'll finally make it into a plugin - but that'll be whole separate tree, not just a simple "Stage" element. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.