Another question while learning the new Famous Engine: When setting a new state for a transitionable, you are allowed to set a callback for when the transition finishes. For me, the transition tweens to the final number for the specified duration, but the callback isn't run. here's my code:
'use strict';
var famous = require('famous');
var DOMElement = famous.domRenderables.DOMElement;
var Transitionable = famous.transitions.Transitionable;
var FamousEngine = famous.core.FamousEngine;
var Node = famous.core.Node;
// Create scene.
var scene = FamousEngine.createScene();
var boxNode = scene.addChild();
boxNode.setSizeMode('absolute', 'absolute')
.setAbsoluteSize(300, 300);
var boxElement = new DOMElement(boxNode);
boxElement.setProperty('background-color', 'lightblue');
var boxTransitionable = new Transitionable(0);
// Callback is specified but it never successfully runs.
boxTransitionable.set(100, { duration: 1000 }, function () { console.log('this never runs'); });
FamousEngine.init();
The reason there is no call to the
callbackfunction is that theTransitionableis updated on aget()and does not complete until all iterations in the queue item have completed.Try this code (uncomment from-to line and try it again):
The
Transitionableis a transition between two states over time (tween). The following code snippet is an example using the Transitionable to position a node using a custom component.