Skip to content

Commit

Permalink
stack.js: make getTarget take an offset
Browse files Browse the repository at this point in the history
Allows us to get the -1 target, -2 target etc.

Signed-off-by: Nathan Cutler <[email protected]>
  • Loading branch information
smithfarm committed Sep 25, 2017
1 parent daa8744 commit 95a62e5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions share/js/core/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,13 @@ define ([
getState = function () {
return _stack[_stack.length - 1].state;
},
getTarget = function () {
return _stack[_stack.length - 1].target;
getTarget = function (offset) {
// offset -1 for target under top target
// offset -2 for two targets down, etc.
if (offset === undefined) {
offset = 0;
}
return _stack[_stack.length + offset - 1].target;
},
getXTarget = function () {
return _stack[_stack.length - 1].xtarget;
Expand Down

0 comments on commit 95a62e5

Please sign in to comment.