add flipcard feature into ox-reveal

This commit is contained in:
2021-01-23 17:02:33 +01:00
parent 79a9cca457
commit 7921df18ac
5 changed files with 187 additions and 17 deletions

93
scripts/flipcard/flipcard.css Executable file
View File

@@ -0,0 +1,93 @@
.reveal .slides section > section {
height: 95%;
}
.reveal li { margin: 0; padding: 0.1em}
.reveal h2 { display: none; }
/* THE MAINCONTAINER HOLDS EVERYTHING */
.fc-maincontainer {
position: absolute;
width: 350px;
height: 460px;
background: none;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
/* THE CARD HOLDS THE FRONT AND BACK FACES */
.fc-thecard{
position: relative;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 20px;
transform-style: preserve-3d;
transition: all 0.8s ease;
}
.fc-header p {
font-size: 2.0em !important;
margin: 0 0 20px 0;
color: #fff;
font-family: "Source Sans Pro", Helvetica, sans-serif;
font-weight: 600;
line-height: 1.2;
letter-spacing: normal;
text-transform: uppercase;
text-shadow: none;
word-wrap: break-word;
}
.fc-flip {
background-color: #4d7d43;
color: #7bdb96;
font-style: italic;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: 0.25em 0;
}
/* THE PSUEDO CLASS CONTROLS THE FLIP ON MOUSEOVER AND MOUSEOUT */
/* .fc-thecard:hover{ */
/* /\* transform: rotateY(180deg); *\/ */
/* } */
/* THE FRONT FACE OF THE CARD, WHICH SHOWS BY DEFAULT */
.fc-thefront{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 20px;
backface-visibility: hidden;
overflow: hidden;
/* background: #ffc728; */
background: #7bdb96;
color: #000;
padding: 30px;
}
/* THE BACK FACE OF THE CARD, WHICH SHOWS ON MOUSEOVER */
.fc-theback{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 20px;
backface-visibility: hidden;
overflow: hidden;
background: #dba57b;
color: #333;
text-align: center;
transform: rotateY(180deg);
padding: 30px;
}

View File

@@ -0,0 +1,31 @@
function flipcard_main() {
var cardFront = document.getElementsByClassName("fc-thefront");
var i;
var flip;
for (i = 0; i < cardFront.length; i++) {
flip = document.createElement("div");
flip.appendChild(document.createTextNode("flip"));
flip.className = "fc-flip";
flip.addEventListener("mouseover", event => {
var flip = event.target;
var front = flip.parentElement;
var card = front.parentElement;
card.style.transform = "rotateY(180deg)";
});
cardFront[i].appendChild(flip);
};
var cardBack = document.getElementsByClassName("fc-theback");
var i;
for (i = 0; i < cardBack.length; i++) {
cardBack[i].addEventListener("mouseleave", flipcard_mouseLeave, true);
}
};
function flipcard_mouseLeave(event) {
if (event.target.className == "fc-theback") {
var back = event.target;
var card = back.parentElement;
card.style.transform = "rotateY(0deg)";
}
};
flipcard_main();