Connect Hammer.js with PixiJS.
Allow us to use Hammer.js
gesture recognizer with PixiJS
instance.
npm install pixi-hammer
var PIXI = require('pixi.js');
var Connector = require('pixi-hammer');
var app = new PIXI.Application(320, 400);
// initialize the Connector
var c = new Connector(app);
// assume we have a PIXI instance
var rect = new PIXI.Graphics();
rect.beginFill(0x000000);
rect.drawRect(100, 100, 100, 100);
app.stage.addChild(rect);
// listen hammer.js event from that instance
c.listen(rect, 'pinch', function(e) {
console.log('pinching on the rect!');
});
Instead of traverse whole PIXI scene graph, this connector cache listeners to its own stack and only check the instance itself and up to the root.
- examples for
stopPropagation
etc
MIT