SHX-Theme/snippets/shx-loading-spinner.liquid

117 lines
3.1 KiB
Plaintext

{% assign content_type = content_type | default: 'body' %}
{% if content_type == 'body' %}
<shx-loading-spinner/>
{% elsif content_type == 'head' %}
<script>
class SHX_LoadingSpinner extends HTMLElement {
constructor() {
super();
this.container = null;
this.hideTimeout = null;
}
connectedCallback() {
this.resetStyles();
}
resetStyles() {
this.innerHTML = `
<div class="shx-loading-spinner-container">
{% render 'shx-logo', class_name:"shx-loading-spinner-mainIcon shx-loading-spinner-unclickable", width:"200px"%}
<p class="shx-loading-spinner-unclickable">Lade Vorschau</p>
</div>
`;
this.container = this.querySelector('.shx-loading-spinner-container');
}
show() {
if(this.hideTimeout) {
clearTimeout(this.hideTimeout);
}
resetStyles();
setTimeout(() => {
this.container.classList.remove('shx-loading-spinner-container-done');
}, 0);
}
hide() {
this.container.classList.add('shx-loading-spinner-container-done');
if (this.hideTimeout) {
clearTimeout(this.hideTimeout);
}
this.hideTimeout = setTimeout(() => {
this.container.style.display = 'none';
}, 1000);
}
}
customElements.define('shx-loading-spinner', SHX_LoadingSpinner);
</script>
<style>
@keyframes shx-spinner-pulse {
0% {
transform: scale(0.85);
}
50% {
transform: scale(1);
}
100% {
transform: scale(0.85);
}
}
.shx-loading-spinner-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.2);
z-index: 9999;
display: flex;
flex-direction: column; /* Add this line */
justify-content: center;
align-items: center;
backdrop-filter: blur(10px);
transition: all 0.5s;
}
.shx-loading-spinner-container-done {
opacity: 0;
pointer-events: none;
}
.shx-loading-spinner-unclickable {
pointer-events: none;
}
.shx-loading-spinner-mainIcon {
animation: shx-spinner-pulse 0.65s cubic-bezier( 0.59, 0.23, 0.28, 0.73) infinite;
filter: drop-shadow(0px 0px 5px rgba(255,255,255, 0.5)), drop-shadow(0px 0px 20px rgba(255,255,255, 0.5));
}
.shx-loading-spinner-container p {
color: white;
font-size: 1.5em;
margin-top: 1em; /* Change margin-left to margin-top */
}
</style>
{% endif %}