x-flipbox
A flipbox acts as an element that can flip between two sides of content, much like a playing card.
Basic usage
An <x-flipbox>
should contain only two direct children elements, each of which can contain any markup.
The first child element will be considered the front face of the <x-flipbox>
.
The last child element will be considered the back face of the <x-flipbox>
.
I'm the front face.
And I'm the back face.
Markup
<x-flipbox>
<div>I'm the front face.</div>
<div>And I'm the back face.</div>
</x-flipbox>
JavaScript
// assume that toggleButton and flipBox are already
// defined as their respective DOM elements
toggleButton.addEventListener("click", function(){
flipBox.toggle();
});
Changing flip direction: direction
To change the direction that the flip animation spins in, users can change either the direction
attribute or the .direction
property of the <x-flipbox>
.
Valid options: "right"
, "left"
, "up"
, "down"


Markup
<x-flipbox>
<div>I'm the front face.</div>
<div>And I'm the back face.</div>
</x-flipbox>