davidfig / pixi-viewport

A highly configurable viewport/2D camera designed to work with pixi.js
https://davidfig.github.io/pixi-viewport/
MIT License
1.04k stars 174 forks source link

Fix removeEventListener error (PixiJS 7) #471

Closed richardsolomou closed 4 months ago

richardsolomou commented 9 months ago

Fixes #438

This pull request adds an optional chaining operator to the events.domElement property when calling removeEventListener. This means that this will no longer error out when the Pixi prematurely destroys the domElement ahead of pixi-viewport.

Also removes the need to do this in userland for @pixi/react:

willUnmount: (viewport: PixiViewport) => {
    viewport.options.noTicker = true;
    viewport.destroy({ children: true });
}

I've tested this locally using pnpm patch on my application and it works wonders.

davidfig commented 4 months ago

Thanks!