Created
October 17, 2009 06:38
-
-
Save xeolabs/212269 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var graph = SceneJs.graph( | |
| SceneJs.node({ | |
| childListeners: { | |
| 'alpha': { | |
| fn: function(nodeContext, event) { | |
| // Event 'alpha' has bubbled up and is handled here again at step 3. | |
| alert('Event name ' + event.name + ' handled with params ' | |
| + event.foo + " and " + event.bar); | |
| } | |
| } | |
| } | |
| }, | |
| SceneJs.node({ | |
| childListeners: { | |
| 'alpha': { | |
| fn: function(nodeContext, event) { | |
| // Event 'alpha' is handled here at step 2. | |
| } | |
| }, | |
| 'beta': { | |
| fn: function(nodeContext, event) { | |
| // Event 'beta' is handled here at step 4. | |
| // Consume it so it doesnt bubble up to parent. | |
| event.consumed = true; | |
| } | |
| } | |
| } | |
| }, | |
| SceneJs.node({ | |
| preVisit : function(nodeContext) { | |
| // Events alpha' and 'beta' are fired from here at step 1. | |
| nodeContext.fireChildEvent('alpha', { | |
| foo: 'foo value', | |
| bar: 'bar value' | |
| }); | |
| nodeContext.fireChildEvent('beta', { | |
| foo: 'foo value', | |
| bar: 'bar value' | |
| }); | |
| } | |
| }) // SceneJs.node | |
| ) // SceneJs.node | |
| ) // SceneJs.node | |
| ); // SceneJs.graph | |
| graph.traverse(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment