Add shake animation for shuffling piles

This commit is contained in:
Adam Goldsmith 2017-09-25 13:10:33 -04:00
parent 1197c82895
commit f38f31ec58
2 changed files with 19 additions and 1 deletions

View File

@ -133,7 +133,14 @@ interact('.card-pile')
container.appendChild(cardList); container.appendChild(cardList);
showModal(container); showModal(container);
}) })
.on('tap', event => shuffle(piles[event.target.getAttribute('data-pile')])); .on('tap', event => {
shuffle(piles[event.target.getAttribute('data-pile')]);
event.target.classList.add("shake");
// reset animation so it can be played again
event.target.onanimationend = e => {
event.target.classList.remove("shake");
};
});
function makeCard(cardNum) { function makeCard(cardNum) {
// draw a new card // draw a new card

View File

@ -39,6 +39,17 @@ body {
user-select: none; user-select: none;
} }
.shake {
animation: shake 0.8s;
}
@keyframes shake {
10%, 90% {transform: translate(-1px, 0);}
20%, 80% {transform: translate(2px, 0);}
30%, 50%, 70% {transform: translate(-4px, 0);}
40%, 60% {transform: translate(4px, 0);}
}
.deck { .deck {
background-color: blue; background-color: blue;
} }