jonobr1/two.js — pull request #17 by acido69 (2013-05-13 23:42:55+00:00)
Title: Feature :: Add DOM events in objects

Add DOM events in Objects
====================

Events supported
-------------------------
SVG: `click`, `mousedown`, `mouseup`, `mouseover`, `mouseout`
Canvas: `mousedown`, `mouseup`
WebGL: *in progress*

Example
------------
```javascript
var two = new Two({
fullscreen: true,
autostart: true,
type: Two.Types.canvas
}).appendTo(document.body);
var path = [
new Two.Vector(50,50),
new Two.Vector(50,60),
new Two.Vector(60,50),
new Two.Vector(60,50),
new Two.Vector(70,60),
new Two.Vector(70,30),
new Two.Vector(50,50)
];
var polygon = two.makePolygon(path, true);

polygon.on('mousedown', function(){ console.log('WIN! polygon mousedown') });
polygon.on('mouseup', function(){ console.log('WIN! polygon mouseup') });
```