Spaces:
Running
Running
Download components/loader-preview.js from dazman72/spingenius-pro: direct link, hf CLI and curl.
- Browser
- Download file 1.93 kB
-
https://huggingface.co/spaces/dazman72/spingenius-pro/resolve/main/components/loader-preview.js
- Command line
-
hf download hf://spaces/dazman72/spingenius-pro/components/loader-preview.js
-
curl -L -o loader-preview.js https://huggingface.co/spaces/dazman72/spingenius-pro/resolve/main/components/loader-preview.js
1.93 kB
| class LoaderPreview extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| :host { | |
| display: block; | |
| width: 100%; | |
| height: 100%; | |
| position: relative; | |
| } | |
| .preview-container { | |
| width: 100%; | |
| height: 100%; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| background: white; | |
| border-radius: 0.5rem; | |
| box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); | |
| overflow: hidden; | |
| } | |
| canvas { | |
| max-width: 100%; | |
| max-height: 100%; | |
| } | |
| </style> | |
| <div class="preview-container"> | |
| <canvas id="loader-canvas"></canvas> | |
| </div> | |
| `; | |
| this.canvas = this.shadowRoot.getElementById('loader-canvas'); | |
| this.ctx = this.canvas.getContext('2d'); | |
| this.setupCanvas(); | |
| this.startAnimation(); | |
| } | |
| setupCanvas() { | |
| const container = this.shadowRoot.querySelector('.preview-container'); | |
| this.canvas.width = container.clientWidth; | |
| this.canvas.height = container.clientHeight; | |
| } | |
| startAnimation() { | |
| const animate = () => { | |
| this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); | |
| // Draw custom loader animation using canvas API | |
| const time = Date.now() * 0.001; | |
| const centerX = this.canvas.width / 2; | |
| const centerY = this.canvas.height / 2; | |
| const radius = Math.min(this.canvas.width, this.canvas.height) * 0.3; | |
| this.ctx.beginPath(); | |
| this.ctx.arc(centerX, centerY, radius, time % (Math.PI * 2), (time + Math.PI) % (Math.PI * 2)); | |
| this.ctx.lineWidth = 8; | |
| this.ctx.strokeStyle = '#3b82f6'; | |
| this.ctx.stroke(); | |
| requestAnimationFrame(animate); | |
| }; | |
| animate(); | |
| } | |
| } | |
| customElements.define('loader-preview', LoaderPreview); |