-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnode.js
More file actions
27 lines (22 loc) · 666 Bytes
/
node.js
File metadata and controls
27 lines (22 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Color Tween node example (use setTimeout or setImmediate instead of requestAnimationFrame)
var tween = new ColorTween('#000', '#FFF')
.duration(1000)
.easing('linear')
.onUpdate(update)
.onEnd(function(){
console.log('nice run');
})
.start(animate);
function animate() {
if (tween.update()) {
setTimeout(animate, 50);
}
// or if you want super smooth by very chatty updates:
// if (tween.update()) {
// setImmediate(animate);
// }
}
function update(color) {
var val = color.hex();
console.log('updating color to', val);
}