Created
November 17, 2014 21:16
-
-
Save christophermina/d4e55ecf60466f35fbcb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var lastHeights = []; | |
var i; | |
for (i = 0; i < this.numColumn; i++) { | |
lastHeights[i+1] = this.gapMargin; | |
} | |
if (cardElems.length > 0) { | |
var x | |
, y | |
, l | |
, j | |
, currCol = 1 | |
, maxHeight = 0 | |
, cardColumns = 1; | |
for (i = 0, l = cardElems.length; i < l; i++) { | |
cardColumns = 1; | |
//Ensure the card isn't being deleted. | |
var cardId = cardElems[i].attributes["card-id"].value; | |
if (this.cards.get(cardId) == null) { | |
continue; | |
} | |
cardColumns = this.setCardColumns(cardElems[i]); | |
if (cardColumns > 1 && this.numColumn - currCol < (cardColumns-1)) { | |
//set height of remaining columsn to that of the previous one | |
var lastHeight = lastHeights[currCol - 1]; | |
for (j = currCol; j <= this.numColumn; j++) { | |
lastHeights[j] = lastHeight; | |
} | |
//Reset currCol to 1 | |
currCol = 1; | |
} | |
this.dragsters.push(new Dragster(cardElems[i])); | |
var card = cardElems[i].querySelector(".card"); | |
var prevHeight = lastHeights[currCol]; | |
if (cardColumns > 1) { | |
for (j = 0; j < cardColumns; j++) { | |
if (lastHeights[currCol+j] > prevHeight) { | |
prevHeight = lastHeights[currCol+j]; | |
} | |
} | |
} | |
lastHeights[currCol] = prevHeight + (card.offsetHeight + this.gapMargin); | |
if (cardColumns > 1) { | |
for(j = 0; j < cardColumns; j++) { | |
lastHeights[currCol + j] = lastHeights[currCol]; | |
} | |
} | |
if (lastHeights[currCol] > maxHeight) { | |
maxHeight = lastHeights[currCol]; | |
} | |
y = prevHeight; | |
x = this.leftRightPaddingMargin + ((currCol-1) * this.cardWidth) + ((currCol-1) * this.gapMargin); | |
if (cardColumns > 1) { | |
currCol = currCol + cardColumns - 1; | |
} | |
if (currCol == this.numColumn) { | |
currCol = 1; | |
} else { | |
currCol++; | |
} | |
this.moveCard(cardElems[i], x, y, i, preventDelay); | |
} | |
cardsContainer.style.height = (maxHeight + this.gapMargin) + 'px'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment