ShukantPal / pixi-essentials

The best goodies for performant, enterprise-level applications built on PixiJS
https://api.pixijs.io
MIT License
285 stars 37 forks source link

[Transformer][Feature] Attach event handlers to Transformer's internal onPointer callbacks #67

Open karmaral opened 2 years ago

karmaral commented 2 years ago

Hello. I'm making a box selection system and found that the e.stopPropagation() from the transformer prevents my callback to be run, so I modified the transformer to accept "attached callbacks" and run them on each of its internal callbacks.

Something like

this._attachedHandlers = {
  'pointerdown': [],
  'pointermove': [],
  'pointerup': [(e) => console.log('pointerUp')]
}

onPointerUp(e) { 
  ...
  e.stopPropagation();
  this._attachedHandlers['pointerup'].forEach(callback => callback(e));
  ...
}

Would it be a welcome addition? If so I could make a pull request once I'm done with it (properly typed and function-wrapped obviously).

ShukantPal commented 1 year ago

Sorry for the delayed response. Seems like a useful feature. I would be ok if you can create a PR with good code.

karmaral commented 1 year ago

No worries. I will once I get back to it!