Memory cards with Javascript
course from Brad Traversy
Features:
localStorage set and get
card flip animation CSS
slide the cards two direction
add, clear cards
HTML
cleat button is on the bottom of the pageadd new card button is on the top of the page with title
the navigation with two buttons and the current card number
CSS
apply perspective to the outside of cardeach card is in an absolute position
when the card is active, change the translalteX and rotateY degree .
when the card is active, change the translalteX and rotateY degree .
with the left class name, change the x axis and rotateY degree
when flip, rotate x
JS
select all the DOM neededinit the array to store all the added cards
the cardsData can be a static array data or get from localStorage
set the localStorage data to cards and then reload
When clicking the add card button, get the value of the question and answer, and create a new card passed with the values.
hide the add container,push the new card data to cardsData array,and set them to localStorage
when clicking the card to flip with toggle class name
and updateCurrentText()
when clicking the prev or next buttons, the card moves with the class name added the index increases. If the active card index reaches the last one , stay at the last one, if the active card index reaches the first one, do the same.
the currentText shows the active card index+1