Skip to content

Commit

Permalink
erg bitten again by setOptions. It's just not
Browse files Browse the repository at this point in the history
safe to use class instances there as values.
  • Loading branch information
swannodette committed Oct 24, 2009
1 parent 17920fb commit ff15bd1
Show file tree
Hide file tree
Showing 3 changed files with 4,047 additions and 32 deletions.
26 changes: 13 additions & 13 deletions FxGraph.js
@@ -1,29 +1,29 @@
Fx.Graph = new Class({
Implements: [Options, Events],

defaults: {

},

initialize: function(el, options) {
this.element = el;
this.setOptions(this.defaults, options);
this.graph = this.options.graph;
this.processStates(this.options.graph);
this.graph = options.graph;
this.processStates(options.graph);
this.element.set('morph', {
duration: this.options.duration,
transition: this.options.transition
duration: options.duration,
transition: options.transition
});
},

processStates: function(graph){
$H(graph).each(function(state, name) {
if(state.events) state.events.each(function(event) {
event.object.addEvent(event.type, function() {
for(var name in graph) {
state = graph[name];
if(state.events) state.events.each(function(evt) {
console.log("adding event", evt.type, "to", evt.obj.name);
console.log(evt.obj == ex);
evt.obj.addEvent(evt.type, function() {
this.setState(name);
}.bind(this));
window.foo = evt.obj;
console.log(evt.obj);
}, this);
}, this);
}
},

state: function() {
Expand Down
40 changes: 21 additions & 19 deletions examples/example.js
Expand Up @@ -5,29 +5,31 @@ var Example = new Class({
name: 'Example',

initialize: function() {
this.fxgraph = new Fx.Graph($('box1'), {
duration: 3000,
transition: Fx.Transitions.Cubic.easeIn,
graph: {
start: {
selector: '.start',
events: [
{type:'step1', object:this, next:'step1'}
]
},
step1: {
selector: '.step1'
}
}
});

$('step1').addEvent('click', function() {
this.fireEvent('step1');
}.bind(this));
console.log("init example");
}
});

var ex;
function init() {
ex = new Example();

var fxgraph = new Fx.Graph($('box1'), {
duration: 3000,
transition: Fx.Transitions.Cubic.easeIn,
graph: {
start: {
selector: '.start',
events: [
{type:'step1', obj:ex, next:'step1'}
]
},
step1: {
selector: '.step1'
}
}
});

$('step1').addEvent('click', function() {
ex.fireEvent('step1');
}.bind(this));
}

0 comments on commit ff15bd1

Please sign in to comment.