Issue with the animation pattern implementation.
francois2metz opened this issue · 1 comments
francois2metz commented
There is a bug with your Animation pattern implementation.
Buffer = {
commands: [],
// Adds a command to the buffer, and executes it if it's the only command
// to be ran.
add: function(fn) {
this.commands.push(fn);
if (this.commands.length == 1) fn();
},
// Moves onto the next command in the buffer.
next: function() {
this.commands.shift();
if (this.commands.length) this.commands.shift()();
}
};
The add function should not call the callback fn but call next instead.
Buffer = {
commands: [],
// Adds a command to the buffer, and executes it if it's the only command
// to be ran.
add: function(fn) {
this.commands.push(fn);
if (this.commands.length == 1) this.next();
},
// Moves onto the next command in the buffer.
next: function() {
if (this.commands.length) this.commands.shift()();
}
};
Cannot provide a pull request because your master branch is not up to date.
Bye,
François
rstacruz commented
Thanks, pushing the latest version now.