Skip to content

Commit

Permalink
Avoid accessing undefined card, see #97
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Nov 17, 2022
1 parent 76b14a8 commit b8679ae
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions js/common/view/CardNodeContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,19 @@ class CardNodeContainer extends Node {

// we know at least one card exists because we're in a dragListener link
const leftmostCard = this.cardNodeCells[ 0 ]!;
dataSortedNode.centerX = getCardPositionX( ( this.cardNodeCells.length - 1 ) / 2 ) + leftmostCard.width / 2;

if ( leftmostCard ) {
dataSortedNode.centerX = getCardPositionX( ( this.cardNodeCells.length - 1 ) / 2 ) + leftmostCard.width / 2;
dataSortedNode.bottom = leftmostCard.top - 7;
}
else {
dataSortedNode.centerX = getCardPositionX( ( this.cardNodeCells.length - 1 ) / 2 );
dataSortedNode.bottom = -7.5;
}

if ( dataSortedNode.left < 0 ) {
dataSortedNode.left = 0;
}
dataSortedNode.bottom = leftmostCard.top - 7;
dataSortedNode.visible = true;
dataSortedNode.opacity = 1;

Expand Down

0 comments on commit b8679ae

Please sign in to comment.