Skip to content

Commit

Permalink
Merge pull request #20 from oncletom/bugfix-samefloor
Browse files Browse the repository at this point in the history
Sending the elevator to the same floor never triggers the next queue element
  • Loading branch information
Thomas Parisot committed Dec 3, 2013
2 parents a478899 + da8569a commit 658f70b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Elevator.js
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

0 comments on commit 658f70b

Please sign in to comment.