Skip to content

thammin/pixi-hammer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pixi-hammer

Connect Hammer.js with PixiJS.

Allow us to use Hammer.js gesture recognizer with PixiJS instance.

Install

npm install pixi-hammer

Usage

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!');
});

How it works

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.

TODO

  • examples for stopPropagation etc

License

MIT

About

Use Hammerjs with pixi

Resources

License

Stars

Watchers

Forks

Packages

No packages published