From 6e6f3189e114e386b12ce51eaffe9f7b8a984a6e Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 28 Sep 2017 17:40:07 -0400 Subject: [PATCH] Allow adding to bottom of pile by holding shift --- js/playfield.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/js/playfield.js b/js/playfield.js index e12a0b3..160fabf 100644 --- a/js/playfield.js +++ b/js/playfield.js @@ -128,11 +128,19 @@ interact('.card-pile') .dropzone({ accept: '.card:not(.in-pile)', ondrop: event => { - // TODO: fix duped zeros + // TODO: fix possible duped zeros let pileName = event.target.getAttribute('data-pile'); let cardNum = event.relatedTarget.getAttribute('data-num'); - console.log(`Adding ${cardNum} to ${pileName}`); - piles[pileName].push(cardNum); + if (event.dragEvent.shiftKey) { + console.log(`Adding ${cardNum} bottom of to ${pileName}`); + piles[pileName].unshift(cardNum); + } + else { + console.log(`Adding ${cardNum} to ${pileName}`); + piles[pileName].push(cardNum); + } + + // remove from DOM event.relatedTarget.parentElement.removeChild(event.relatedTarget); // update deck text