ericdrowell / KineticJS

KineticJS is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://www.kineticjs.com
3.98k stars 754 forks source link

Event Capture Phase as well as Bubbling Supported? #671

Closed sanielfishawy closed 10 years ago

sanielfishawy commented 11 years ago

Both Capture and Bubble Supported?

Do events that propagate through the Kinetic tree support both javascript like Capture Phase as well as Bubbling Phase?

Background for the question:

In javascript events that propagate through the DOM do so in two phases: 1) Capture phase where events propagate downward from the highest parent all the way to the leaf children.

2) Bubbling where events bubble up from the lowest leaf nodes to the highest parent.

Reason for wanting Capture as well as Bubbling:

I am using Kinetic for a robotic modeling and control application. Imagine that you have a robot which is composed of many Kinetic parts. Imagine proximity sensors for example that are oriented on the robot in a particular geometry. Now lets say for example I move the robot:

ericdrowell commented 11 years ago

cool app!

Currently I do not intend to support the capturing phase. Your use case could be easily handled by listening for an event on a Kinetic Node, and then attaching an event handler that traverses the children and does something with each, like this:

node.getChildren().each(function(child) { // do something with each child, or traverse downwards further });

sanielfishawy commented 11 years ago

Yup. Thanks. That is exactly what I did.

Sani

On Sat, Nov 2, 2013 at 12:48 PM, Eric Rowell notifications@github.comwrote:

cool app!

Currently I do not intend to support the capturing phase. Your use case could be easily handled by listening for an event on a Kinetic Node, and then attaching an event handler that traverses the children and does something with each, like this:

node.getChildren().each(function(child) { // do something with each child, or traverse downwards further });

— Reply to this email directly or view it on GitHubhttps://github.com/ericdrowell/KineticJS/issues/671#issuecomment-27630863 .

Sani El-Fishawy elfishawy.sani@gmail.com 650-245-3537