-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring to pseudoclassical complete
- Loading branch information
1 parent
1e7740c
commit ecb156a
Showing
3 changed files
with
20 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
// Creates and returns a new dancer object that can step | ||
var Dancer = function(top, left, timeBetweenSteps) { | ||
this.top = top; | ||
this.left = left; | ||
var makeDancer = function(top, left, timeBetweenSteps) { | ||
// this.top = top; | ||
// this.left = left; | ||
this.timeBetweenSteps = timeBetweenSteps; | ||
|
||
// use jQuery to create an HTML <span> tag | ||
this.$node = $('<span class="dancer"></span>'); | ||
|
||
//console.log('What is this? How do we refer to this in a meaning context?', this); | ||
this.step(); | ||
// I THINK that 'this' refers to the newly instantiated object | ||
makeDancer.prototype.step.call(this); | ||
|
||
this.setPosition(top, left); | ||
|
||
}; | ||
|
||
|
||
Dancer.prototype.step = function() { | ||
makeDancer.prototype.step = function() { | ||
// the basic dancer doesn't do anything interesting at all on each step, | ||
// it just schedules the next step | ||
|
||
setTimeout(this.step.bind(this), this.timeBetweenSteps); //refactor setTimeout with bind | ||
}; | ||
|
||
Dancer.prototype.setPosition = function(top, left) { | ||
makeDancer.prototype.setPosition = function(top, left) { | ||
// Use css top and left properties to position our <span> tag | ||
// where it belongs on the page. See http://api.jquery.com/css/ | ||
// | ||
var styleSettings = { | ||
top: this.top, | ||
left: this.left | ||
top: top, | ||
left: left | ||
}; | ||
this.$node.css(styleSettings); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,6 @@ $(document).ready(function() { | |
}); | ||
}); | ||
|
||
|
||
// somewhere, we need a 'new' keyword! | ||
|