From 673d16d8f2fb9d7b7df5f6fcadfbc665f329887c Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Tue, 29 Sep 2020 01:53:49 -0400 Subject: More drag updates --- scripts/cards/card.js | 12 +++++++++++- scripts/cards/deck.js | 16 +++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'scripts/cards') diff --git a/scripts/cards/card.js b/scripts/cards/card.js index 750d124..884e0d9 100644 --- a/scripts/cards/card.js +++ b/scripts/cards/card.js @@ -7,12 +7,16 @@ const CardPos = ["top", "topl", "topr", "mid", "midt", "midb", "bot", "botl", "b // Every card should have a deck. // Use deck.appendCard or deck.prependCard to make a card visible class Card { - constructor (data) + constructor (id, data) { this.e = document.createElement("card"); this.generateElements(data); this.e.style.left = "0px"; this.e.style.top = "0px"; + + this.getID = function() { + return id; + } } // Generate a card with basic text only @@ -107,4 +111,10 @@ class Card { { this.e.style.setProperty("--cpos", p); } + + resetPos() + { + this.e.style.left = "0px"; + this.e.style.top = "0px"; + } } diff --git a/scripts/cards/deck.js b/scripts/cards/deck.js index 6da24b0..d87d619 100644 --- a/scripts/cards/deck.js +++ b/scripts/cards/deck.js @@ -13,7 +13,7 @@ class Deck { y = 0; e = null; - constructor(options = {mode: "stack", smode: "one", sct: 0, pos: [0, 0]}) + constructor(id, options = {mode: "stack", smode: "one", sct: 0, pos: [0, 0]}) { // View mode // infdraw - infinite draw. always appears as if there are multiple cards @@ -54,6 +54,10 @@ class Deck { this.e.style.left = this.x + "px"; this.e.style.top = this.y + "px"; this.e.setAttribute("mode", options.mode); + + this.getID = function() { + return id; + } } updatePos() @@ -143,4 +147,14 @@ class Deck { var rect = this.e.getBoundingClientRect(); return (x > rect.left && x < rect.right && y > rect.top && y < rect.bottom) } + + checkCard (el) + { + for(let c of this.cards) + { + if(c.e === el) + return c; + } + return null; + } } -- cgit v1.2.3