pixijs / pixi-react

Write PIXI apps using React declarative style
https://pixijs.io/pixi-react/
MIT License
2.25k stars 173 forks source link

Bug: parent container's event is triggered twice. #429

Open mathedu4all opened 1 year ago

mathedu4all commented 1 year ago

Current Behavior

parent container's event is triggered twice.

Expected Behavior

parent container's event should be triggered once as child.

Steps to Reproduce

import { Container, createRoot, Graphics } from '@pixi/react'
import { Application, ICanvas } from 'pixi.js'
import React from 'react'
import * as PIXI from 'pixi.js'

const container = document.getElementById('container') as unknown as ICanvas
if (container) {
  const app = new Application({
    width: 1080,
    height: 1920,
    view: container,
    antialias: true,
    backgroundColor: 0xf0e1d8
  })
  const root = createRoot(app.stage)
  const draw = (g: PIXI.Graphics) => {
    g.beginFill(0x000000)
    g.drawRect(0, 0, 100, 100)
    g.endFill()
  }
  root.render(
    <Container eventMode={'static'} onpointerdown={() => console.log('down')}>
      <Container eventMode={'static'} onpointerup={() => console.log('up')}>
        <Graphics draw={draw} />
      </Container>
    </Container>
  )
}

Environment

Possible Solution

No response

Additional Information

No response