pixi-viewport icon indicating copy to clipboard operation
pixi-viewport copied to clipboard

Uncaught TypeError: Cannot read property 'parentElement' of null

Open cannc4 opened this issue 5 years ago • 4 comments

Hello, thanks a lot for creating this library!

I've been consistently hitting the following error when I try to do scale/wheel/pinch operations and wanted to report it

Uncaught TypeError: Cannot read property 'parentElement' of null
    at InteractionManager.push.../node_modules/@pixi/interaction/lib/interaction.es.js.InteractionManager.mapPositionToPoint (interaction.es.js:1611)
    at InputManager.getPointerPosition (viewport.es.js:172)
    at InputManager.handleWheel (viewport.es.js:191)
    at HTMLBodyElement.wheelFunction (viewport.es.js:41)

image

cannc4 avatar Nov 02 '20 19:11 cannc4

Is your viewport.options.interaction set properly?

davidfig avatar Nov 02 '20 23:11 davidfig

I am a bit unsure about the proper setting for that I am passing app.renderer.plugins.interaction to interaction object as far as I know

cannc4 avatar Nov 03 '20 10:11 cannc4

This happens when you destroy your renderer and the viewport is still listening to the wheel event on the divWheel. You should add a listener to renderer destroy and destroy the viewport.

renderer.runners['destroy'].add({
  destroy: viewport.destroy.bind(viewport)
})

ShukantPal avatar Nov 25 '20 14:11 ShukantPal

in my case, I have the code invoke PIXI.Application instance's destroy() and encountered same error.

after change PIXI.Application instance's destroy method parameter, to destroy every children including viewport, seem to be solved for now.

app.destroy(boolean, {children: true});

laranhee avatar Feb 16 '21 14:02 laranhee