-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
80 lines (65 loc) · 2.18 KB
/
App.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
var time = new Date();
window.onload = function() {
// create a new instance of App
app = new App();
// create new object to animate for testing
app.addAnimatedObjects();
};
/* Application Class
initializes javascript that hooks into controls and the animation screen
binds control buttons
*/
function App() {
// set attributes for the state of the app
this.recording = false;
this.playing = false;
// initialize the Timeline object
this.timeline = new Timeline();
// initialize the animationArea
var animationArea = new AnimationArea();
this.animationArea = animationArea;
// initialize record, play buttons
var recordButtonElement = document.getElementById('record');
// temporary binding for debugging
recordButtonElement.addEventListener('click', function() {
app.timeline.createThumbnail();
})
// this.recordbutton = new Button(recordButtonElement);
var playButtonElement = document.getElementById('play');
playButtonElement.addEventListener('click', function() {
animationArea.playAllAnimations();
});
// temporary button
var pauseButtonElement = document.getElementById('pause');
pauseButtonElement.addEventListener('click', function() {
animationArea.pauseAllAnimations();
});
this.objectsListControl = $("#objectsList");
// initialize add object button
var addAnimatedObjectButton = document.getElementById('addObject');
addAnimatedObjectButton.addEventListener('click', function(e){
e.preventDefault();
console.log('hey');
$('#addObjectModal').reveal();
});
}
App.prototype.record = function(params) {
// figure out which element is selected
// tell it to record its position every 1/24 of a second
// activate the timeline
}
App.prototype.play = function(params) {
// command all objects to animate themselves, make sure time offsets work
}
// upload a new image to animate
App.prototype.addAnimatedObjects = function() {
var objects = [
{'name': "StickMan", 'file': "animated-images/stick-figure.jpg"},
{'name': "Tardis", 'file': "animated-images/tardis.png"}
];
var i;
for (i=0; i < objects.length; i++) {
var animatedObj = new AnimatedObject(objects[i]['name'], objects[i]['file']);
this.animationArea.addAnimatedObject(animatedObj);
}
}