From 20201f77b5cf5cbb1c70b1cc51c4108d620a3202 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Sun, 17 May 2020 20:31:10 -0400 Subject: [Webcards] styles and some fixes + Fixed draging transformed cards + Fixed mobile styles + Theme template complete --- webcards/scripts/cards/deck.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'webcards/scripts/cards/deck.js') diff --git a/webcards/scripts/cards/deck.js b/webcards/scripts/cards/deck.js index 620a038..a02142d 100644 --- a/webcards/scripts/cards/deck.js +++ b/webcards/scripts/cards/deck.js @@ -44,17 +44,20 @@ function Deck (options = {mode: "stack", smode: "one", sct: 0, pos: [0, 0]}){ this.e.setAttribute("mode", options.mode); } +//Decks work as FIFO Deck.prototype = { // Add a card to the front of the deck appendCard: function(card) { this.cards.push(card); this.e.appendChild(card.e); + this.updatePos(); }, // Add a card to the back of the deck prependCard: function(card) { this.cards.unshift(card); this.e.prepend(card.e); + card.setPos(this.cards.length - 1); }, // Add a card at the index specified @@ -105,5 +108,11 @@ Deck.prototype = { this.e.removeChild(this.cards[index].e); return this.cards.splice(index, 1)[0]; + }, + + updatePos: function() { + let len = this.cards.length - 1; + for(let i in this.cards) + this.cards[i].setPos(len-i); } }; \ No newline at end of file -- cgit v1.2.3