Created
October 17, 2009 06:46
-
-
Save xeolabs/212271 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({ | |
| preVisit:function(nodeContext) { | |
| // Events 'alpha' and 'beta' are fired from here at Step 1. | |
| nodeContext.fireParentEvent('alpha', { | |
| foo: 'foo value', | |
| bar: 'bar value' | |
| }); | |
| nodeContext.fireParentEvent('beta', { | |
| foo: 'foo value', | |
| bar: 'bar value' | |
| }); | |
| } | |
| }, | |
| SceneJs.node({ | |
| parentListeners: { | |
| 'alpha': { | |
| fn: function(nodeContext, event) { | |
| // Event 'alpha' is handled here at step 2 and is consumed so that it stops here. | |
| // Parent events are handled just prior to preVisit. | |
| event.consumed = true; | |
| } | |
| }, | |
| 'beta': { | |
| fn: function(nodeContext, event) { | |
| // Event 'beta' is handled here at step 3. | |
| } | |
| } | |
| } | |
| }), // SceneJs.node | |
| SceneJs.node({ | |
| parentListeners: { | |
| 'beta' : { | |
| fn: function(nodeContext, event) { | |
| // Event 'beta' is handled again here at step 4. | |
| } | |
| } | |
| } | |
| }, | |
| SceneJs.node( | |
| SceneJs.Node({ | |
| parentListeners: { | |
| 'beta': { | |
| fn: function(nodeContext, event) { | |
| // Event 'beta' is handled yet again here at step 5. | |
| } | |
| } | |
| } | |
| }) | |
| ) // 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