-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnimationArea.js
59 lines (49 loc) · 1.4 KB
/
AnimationArea.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* AnimationArea Class
contains all of the animated objects
enforces bounds
might be extensible
when things get uploaded, they get added here
*/
function AnimationArea() {
// hold onto animated objects
this.animatedObjects = [];
this.currentTime = 0;
this.areaElement = $('#animationArea');
this.init();
};
AnimationArea.prototype.init = function() {
// initialize kinetic.js stage
this.stage = new Kinetic.Stage({
container: 'animationArea',
height: this.areaElement.height(),
width: this.areaElement.width()
})
this.layer = new Kinetic.Layer();
this.stage.add(this.layer);
}
AnimationArea.prototype.addAnimatedObject = function(animatedObject) {
var number = this.animatedObjects.length;
// assign number to animated object
animatedObject.number = number;
this.animatedObjects.push(animatedObject);
};
/* iterates over all animated objects in the animation area
and calls playAnimation on each one
*/
AnimationArea.prototype.playAllAnimations = function() {
var i;
for (i=0; i < this.animatedObjects.length; i++) {
var animatedObject = this.animatedObjects[i];
animatedObject.playAnimation();
}
};
AnimationArea.prototype.pauseAllAnimations = function() {
debugger;
var i;
for (i=0; i < this.animatedObjects.length; i++) {
var animatedObject = this.animatedObjects[i];
animatedObject.pauseAnimation();
}
};
AnimationArea.prototype.mapToAllAnimations = function(functionToMap) {
};