In famo.us, there are some easy ways to perform animations/interactions using modifiers on a surface. For instance, dragging and animating surfaces have pretty straight forward examples in the famo.us guides.
...assume require('') statements above here...
var mainContext = Engine.createContext();
var draggable = new Draggable({...});
var surface = new Surface({...});
var transitionableTransform = new TransitionableTransform();
var modifier = new Modifier({
origin: [.5, .5],
transform: transitionableTransform
});
surface.pipe(draggable);
surface.on('click', function () {
transitionableTransform.setScale([3, 3, 1], {duration: 300});
});
mainContext.add(draggable).add(surface);
However, in more complicated scenarios you might want to coordinate multiple animations, starting/stopping/reversing as needed depending on the interaction. In those cases, things as simple as adding transforms with a duration might work at first, but aren't guaranteed to not fall out of sync the more the user interacts with them.
The #render method appears to be a common place to put some types of coordinated animation. My limited understanding of it is it identifies the 'specs' of nodes that are being rendered, and is called on each frame of the render loop. So you might be able to identify each step of a particular animation, then depending on how it's interacted with be able to stop mid animation and change as needed. For instance, Flipper seems to work this way
(src/views/Flipper.js):
Flipper.prototype.render = function render() {
var pos = this.state.get(); //state is a transitionable
var axis = this.options.direction;
var frontRotation = [0, 0, 0];
var backRotation = [0, 0, 0];
frontRotation[axis] = Math.PI * pos;
backRotation[axis] = Math.PI * (pos + 1);
if (this.options.cull && !this.state.isActive()) {
if (pos) return this.backNode.render();
else return this.frontNode.render();
}
else {
return [
{
transform: Transform.rotate.apply(null, frontRotation),
target: this.frontNode.render()
},
{
transform: Transform.rotate.apply(null, backRotation),
target: this.backNode.render()
}
];
}
};
Is there any documentation on the role #render should play when animating? Or how exactly the render method is supposed to work (for instance, the correct way to construct the specs that get returned). Is render supposed to be more low-level, and if so should a different construct be used?