Create an instance of <helium-animated-pages>
in your HTML page. You can also use any framework that supports rendering Custom Elements.
<style>
.page-fadeIn {
animation: fadeIn 0.7s ease both;
}
@keyframes fadeIn {
from {
opacity: 0.3;
}
to {
}
}
.page-fadeOut {
animation: fadeOut 0.7s ease both;
}
@keyframes fadeOut {
from {
}
to {
opacity: 0;
}
}
</style>
<section>
<h2>Select a page</h2>
<select id="selector">
<option value="page1">Page 1</option>
<option value="page2">Page 2</option>
<option value="page3">Page 3</option>
</select>
</section>
<helium-animated-pages id="pages" attrForSelected="name">
<section name="page1">Page 1</section>
<div name="page2">Page 2</div>
<custom-element name="page3"></custom-element>
</helium-animated-pages>
<script>
document.querySelector('#selector').addEventListener('change', e => {
document.querySelector('#pages').selected = e.target.value;
});
document.querySelector('#pages').animationClasses = {
page1_page2: {
in: 'page_moveFromRight',
out: 'page_moveToLeft',
},
'*_page2': {
in: 'page_moveFromLeft',
out: 'page_moveToRight',
},
'page1_*': {
in: 'page_moveFromTop',
out: 'page_moveToBottom',
},
_page1: {
in: 'page_moveFromBottom',
out: 'page_moveToTop',
},
default: {
in: 'page-fadeIn',
out: 'page-fadeOut',
},
};
</script>