Spaces:
Sleeping
Sleeping
Download src/ObjectStudy.svelte from budijuarto/kriyatrack: direct link, hf CLI and curl.
- Browser
- Download file 2.44 kB
-
https://huggingface.co/spaces/budijuarto/kriyatrack/resolve/main/src/ObjectStudy.svelte
- Command line
-
hf download hf://spaces/budijuarto/kriyatrack/src/ObjectStudy.svelte
-
curl -L -o ObjectStudy.svelte https://huggingface.co/spaces/budijuarto/kriyatrack/resolve/main/src/ObjectStudy.svelte
2.44 kB
| <script> | |
| import { onMount } from 'svelte'; | |
| let { label='Gulungan benang', compact=false }=$props(); | |
| let host; | |
| let turn,reset,broken=$state(false),ready=$state(false); | |
| onMount(()=>{ | |
| let disposed=false,release,watch; | |
| async function load(){ | |
| try{ | |
| const {mountStudy}=await import('./object-study.js'); | |
| if(disposed)return; | |
| const scene=mountStudy(host,label); | |
| turn=scene.turn; reset=scene.reset;release=scene.dispose;ready=true; | |
| }catch{broken=true;} | |
| } | |
| if('IntersectionObserver' in window){watch=new IntersectionObserver(entries=>{if(entries.some(e=>e.isIntersecting)){watch.disconnect();load();}},{rootMargin:'160px'});watch.observe(host);} | |
| else load(); | |
| return ()=>{disposed=true;watch?.disconnect();release?.();}; | |
| }); | |
| </script> | |
| <figure class:compact class="study"> | |
| <div class="stage" bind:this={host} role="img" aria-label={label+' dalam tiga dimensi'} data-ready={ready}> | |
| {#if broken}<span class="fallback">{label}</span>{/if} | |
| </div> | |
| <figcaption><span>{label} <small>3D</small></span> | |
| {#if ready}<span class="controls"><button type="button" title="Putar ke kiri" aria-label={'Putar '+label+' ke kiri'} onclick={()=>turn(-1)}>‹</button><button type="button" title="Putar ke kanan" aria-label={'Putar '+label+' ke kanan'} onclick={()=>turn(1)}>›</button></span>{/if} | |
| </figcaption> | |
| </figure> | |
| <style> | |
| .study{margin:0;color:inherit;max-width:100%;width:100%}.stage{width:100%;height:190px;cursor:grab;touch-action:pan-y;display:grid;place-items:center}.stage:active{cursor:grabbing}.stage :global(svg){width:100%;height:100%;display:block}.compact .stage{height:115px} | |
| .study figcaption{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.65rem;font-size:13px;font-weight:500;line-height:1.4}.study small{font:600 9px/1 monospace;letter-spacing:.03em;vertical-align:super} | |
| .controls{display:inline-flex;gap:4px}.controls button{display:inline-grid;place-items:center;border:1px solid currentColor;background:transparent;color:inherit;min-width:44px;min-height:44px;padding:0;border-radius:3px;cursor:pointer;font:20px/1 sans-serif} | |
| .controls button:focus-visible{outline:2px solid currentColor;outline-offset:2px}.fallback{font-size:.9rem}.study :global(.study-caption){letter-spacing:.03em} | |
| @media(max-width:600px){.compact .stage{height:94px}.stage{height:155px}} | |
| @media print{.study{display:none}} | |
| </style> | |