Skip to content

Commit 6f1c9da

Browse files
committed
working version
1 parent 6663202 commit 6f1c9da

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

our_script.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function Node(paper, nodeName, startX) {
2828

2929
this.highlightNode = function() {
3030
console.log('in highlightNode for node ' + that);
31-
that.circle.attr({fill: 'red'});
31+
// that.circle.attr({fill: 'red'});
3232
this.paper.text(that.startX + ARM_LEN + NODE_RADIUS, HORIZON, that.nodeName).attr({"font-size": 12});
3333
}
3434
};
@@ -51,8 +51,9 @@ function MiddlewareStack() {
5151

5252
function Animation(paper, name) {
5353
var that = this; // Create a handle to the current animation
54+
console.log('created a new Animation object');
5455
this.paper = paper;
55-
this.requestBall = this.paper.circle(0, HORIZON, 5).attr({fill: 'red'});
56+
this.requestBall = this.paper.circle(0, HORIZON, 5).attr({fill: 'green'});
5657
this.name = name;
5758

5859
this.steps = [];
@@ -62,12 +63,15 @@ function Animation(paper, name) {
6263
};
6364

6465
this.run = function(step) {
66+
console.log(this.steps, step)
6567
this.animateRequestBall(this.steps[step]);
6668
};
6769

6870
this.animateRequestBall = function(destination) {
71+
6972
console.log('in animate destination is ' + destination);
7073
var centerOfNode = destination.startX + ARM_LEN + NODE_RADIUS;
74+
console.log(centerOfNode);
7175
var anim = Raphael.animation({cx: centerOfNode, cy: HORIZON}, SPEED, destination.highlightNode);
7276
this.requestBall.animate(anim);
7377
destination = this.steps[step++];
@@ -91,6 +95,7 @@ function displayRailsMiddlewareStack() {
9195
// We will add nodes representing each of the middlewares in the stack we are displaying.
9296
// For now, just make 4 generic nodes to play with while I figure out my API.
9397
var configureMiddleware = function(middlewares) {
98+
console.log("configureMiddleware", middlewares)
9499
var middlewares = middlewares;
95100
for(var i = 0; i < 4; i+=1) {
96101
// Create new node with paper, nodeName, and startX parameters
@@ -102,6 +107,7 @@ function displayRailsMiddlewareStack() {
102107
// For each middleware stack, we will provide sets of animations
103108
animation1 = function() {
104109
var anim = new Animation(p, 'First Animation');
110+
console.log("animation1", middlewares.nodes)
105111
anim.addStep(middlewares.nodes[0]);
106112
anim.addStep(middlewares.nodes[1]);
107113
anim.addStep(middlewares.nodes[2]);
@@ -110,12 +116,15 @@ function displayRailsMiddlewareStack() {
110116
return anim;
111117
};
112118

119+
configureMiddleware(middlewares);
120+
var ourAnimation = animation1();
113121
var runAnimation = function() {
114-
animation1().run(step);
122+
ourAnimation.run(step);
115123
}
116124

117125
// OK now actually do stuff
118-
configureMiddleware(middlewares);
126+
127+
console.debug("middlewares before draw", middlewares)
119128
middlewares.draw();
120129
$('#canvas_container').on("click", runAnimation);
121130
};

0 commit comments

Comments
 (0)