UNPKG

ldrs

Version:

Minimalist loading animations for React and web components

3 lines (2 loc) 3.12 kB
import e from"../lib/LdrsBaseElement.js";var t=":host{--uib-dot-size:calc(var(--uib-size)/2);align-items:center;display:inline-flex;flex-shrink:0;height:var(--uib-size);justify-content:center;width:var(--uib-size)}:host([hidden]){display:none}.container{align-items:center;animation:rotate calc(var(--uib-speed)*2) linear infinite;display:flex;height:calc(var(--uib-size)/2);justify-content:space-between;position:relative;width:var(--uib-size);will-change:transform}.svg{filter:url(#uib-jelly-ooze);overflow:visible}.dot{cy:50%;cx:50%;r:calc(var(--uib-dot-size)/2);fill:var(--uib-color);display:block;transform-box:fill-box;transform-origin:center;transition:fill .3s ease;will-change:transform}.dot:first-child{animation:shift-left var(--uib-speed) ease infinite}.dot:nth-child(2){animation:shift-right var(--uib-speed) ease infinite}@keyframes rotate{0%,49.999%,to{transform:none}50%,99.999%{transform:rotate(90deg)}}@keyframes shift-left{0%,to{transform:scale(1) translateX(0)}50%{transform:scale(.65) translateX(-75%)}}@keyframes shift-right{0%,to{transform:scale(1) translateX(0)}50%{transform:scale(.65) translateX(75%)}}";class s extends e{_attributes=["size","color","speed"];size;color;speed;static get observedAttributes(){return["size","color","speed"]}constructor(){super(),this.storePropsToUpgrade(this._attributes),this.reflect(this._attributes)}connectedCallback(){this.upgradeStoredProps(),this.applyDefaultProps({size:40,color:"black",speed:.9});const e=parseInt(this.size)/2;this.template.innerHTML=`\n <div\n class="container"\n >\n <svg \n class="svg" \n x="0px" \n y="0px"\n viewBox="0 0 ${this.size} ${e}"\n height="${e}"\n width="${this.size}"\n preserveAspectRatio='xMidYMid meet'\n >\n <circle class="dot" />\n <circle class="dot" />\n <defs>\n <filter id="uib-jelly-ooze">\n <feGaussianBlur\n in="SourceGraphic"\n stdDeviation=${parseInt(this.size)/8}\n result="blur"\n />\n <feColorMatrix\n in="blur"\n mode="matrix"\n values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7"\n result="ooze"\n />\n <feBlend in="SourceGraphic" in2="ooze" />\n </filter>\n </defs>\n </svg> \n </div>\n <style>\n :host{\n --uib-size: ${this.size}px;\n --uib-color: ${this.color};\n --uib-speed: ${this.speed}s;\n }\n ${t}\n </style>\n `,this.shadow.replaceChildren(this.template.content.cloneNode(!0))}attributeChangedCallback(){const e=this.shadow.querySelector("style");e&&(e.innerHTML=`\n :host{\n --uib-size: ${this.size}px;\n --uib-color: ${this.color};\n --uib-speed: ${this.speed}s;\n }\n ${t}\n `)}}var i={register:(e="l-jelly")=>{customElements.get(e)||customElements.define(e,class extends s{})},element:s};export{i as default}; //# sourceMappingURL=jelly.js.map