Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending the elevator to the same floor never triggers the next queue element #20

Merged
merged 1 commit into from
Dec 3, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/Elevator.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@
goingToFloor: 1,
previousFloor: 1,
initialize: function(){
var self = this;

//we do it here otherwise the stack is shared among the various elevators (and we don't want it)
this.requestsStack = [];

this.el.addEventListener('transitionend', animationEnd.bind(self));
this.el.addEventListener('webkitTransitionEnd', animationEnd.bind(self));
this.el.addEventListener('transitionend', animationEnd.bind(this));
this.el.addEventListener('webkitTransitionEnd', animationEnd.bind(this));
},
states: {
/**
Expand Down Expand Up @@ -91,10 +89,13 @@
*
* @api
* @param floor_number
* @returns {*}
* @returns {Elevator}
*/
goToFloor: function(floor_number){
if (~this.requestsStack.indexOf(floor_number) === 0){
if (
this.requestsStack.indexOf(floor_number) === -1
&& this.previousFloor !== floor_number
){
this.requestsStack.push(floor_number);
this.handle('move', floor_number);
}
Expand Down