# 기상청 날씨누리 · 레이더로 비구름 이동 보기

날씨누리 레이더에서 시간 간격을 설정하고 재생을 누르면 관측 영상이 시간순으로 바뀝니다. 비구름의 위치를 자세히 보고 싶은 시점에 같은 버튼을 눌러 멈춥니다.

[공식 원문](https://www.weather.go.kr/w/weather/radar/radar.do)

## 관련 모션 · 타임라인 스크러버

# 타임라인 스크러버 (Timeline Scrubber)

재생 헤드를 옮긴 시간에 해당하는 애니메이션 프레임을 즉시 표시합니다.

## 체험 방법

재생하거나 시간 막대를 끌어 해와 산의 장면을 바꿔 보세요.

## 재현 기준

총 8초를 0.1초 단위로 탐색합니다. 수동 탐색은 재생을 멈추고 해당 프레임을 유지합니다. 끝에서 재생하면 처음부터 시작합니다.

## 기기별 조작

- iOS · 시간 막대를 눌러 이동하거나 손가락으로 밀어 프레임을 비교하세요.
- Android · 시간 막대를 눌러 이동하거나 손가락으로 밀어 프레임을 비교하세요.
- PC · 시간 막대를 끌거나 초점을 둔 채 좌우 방향키로 0.1초씩 이동하세요.

## 적용할 때

짧은 영상이나 동작의 특정 순간을 확인할 때.

## 그대로 보낼 요청

> 재생 헤드와 프레임을 동기화하고 정지한 상태에서도 원하는 장면을 탐색하게 해줘.

## 참고한 동작

[W3C WAI · Media Seek Slider](https://www.w3.org/WAI/ARIA/apg/patterns/slider/examples/slider-seek/)

## 독립 실행 코드

아래 전체 코드를 HTML로 저장해 브라우저에서 엽니다.

```html
<!doctype html>
<html lang="ko"><head><script>if(new URLSearchParams(location.search).get('reduce')==='1')document.documentElement.classList.add('motion-reduced');</script><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>타임라인 스크러버 · Motion Lab</title>
<style>
*{box-sizing:border-box}body{margin:0;font-family:system-ui,-apple-system,"Malgun Gothic",sans-serif;word-break:keep-all}button,input{font:inherit}button{cursor:pointer}button:focus-visible,input:focus-visible,[tabindex]:focus-visible{outline:3px solid #ef7c30;outline-offset:2px}button:disabled{cursor:default}button{touch-action:manipulation}.sr-only{position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
body{min-height:100svh;display:grid;place-items:center;padding:18px;background:#202627;color:#f6f0e1}
main{width:min(100%,690px)}header{display:flex;align-items:baseline;justify-content:space-between;gap:10px;padding:0 0 11px}h1{font-size:clamp(22px,4vw,34px);letter-spacing:-.06em;margin:0}.running-time{font:12px/1.3 monospace;color:#d0d6cc}
figure{margin:0;position:relative;overflow:hidden;background:#d5a075}.screen{position:relative;height:clamp(165px,51svh,300px)}canvas{display:block;width:100%;height:100%}.screen::after{content:"";position:absolute;inset:9px;border:1px solid #fff8;pointer-events:none}
figcaption{display:flex;justify-content:space-between;align-items:center;gap:10px;background:#eae5d6;color:#262927;padding:8px 12px;font:600 12px/1.3 monospace}figcaption em{font:italic 17px/1 Georgia,serif}
.transport{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:12px;align-items:center;margin-top:7px}button{min-height:44px;padding:6px 10px;border:1px solid #737c77;background:transparent;color:#fff5dc;border-radius:4px;font-size:13px}button:hover{background:#353d38}#timeline{width:100%;height:44px;accent-color:#ffbb74;cursor:ew-resize;margin:0}output{white-space:nowrap;font:14px/1.35 monospace;font-variant-numeric:tabular-nums}.ticks{display:flex;justify-content:space-between;padding:0 2px 5px;border-bottom:1px solid #66716a;font:11px monospace;color:#ced2c7}
@media(max-width:420px){body{padding:11px}.transport{gap:6px}h1{font-size:23px}output{font-size:12px}.running-time{font-size:10px}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.001ms!important;transition-duration:.001ms!important;scroll-behavior:auto!important}}.motion-reduced *,.motion-reduced *::before,.motion-reduced *::after{animation-duration:.001ms!important;transition-duration:.001ms!important;scroll-behavior:auto!important}
</style></head><body>
<main><header><h1>모래 능선</h1><span class="running-time">8초 / 모션 필름</span></header>
<figure><div class="screen"><canvas id="film" role="img" aria-label="해의 위치와 모래 능선의 구도가 시간에 따라 바뀌는 판화 영상"></canvas></div><figcaption><em lang="en">Dune passage</em><span id="frame">F 000</span></figcaption></figure>
<div class="transport"><button id="play" type="button">▶ 재생</button><input id="timeline" aria-label="재생 위치" type="range" min="0" max="8" step="0.1" value="1.6"><output id="time" aria-live="off">1.6초</output></div><div class="ticks" aria-hidden="true"><span>0s</span><span>2s</span><span>4s</span><span>6s</span><span>8s</span></div></main>
<script>
const canvas=document.querySelector('#film'),ctx=canvas.getContext('2d'),range=document.querySelector('#timeline'),play=document.querySelector('#play');
const tau=Math.PI*2;
let time=1.6,raf=0,origin=0;
function blend(a,b,k){return 'rgb('+a.map((v,i)=>Math.round(v+(b[i]-v)*k)).join(',')+')';}
function draw(){
  const r=canvas.getBoundingClientRect(),dpr=Math.min(devicePixelRatio||1,2),width=Math.max(1,Math.round(r.width*dpr)),height=Math.max(1,Math.round(r.height*dpr));
  if(canvas.width!==width||canvas.height!==height){canvas.width=width;canvas.height=height;}
  ctx.setTransform(width/800,0,0,height/330,0,0);
  const t=time/8, late=t*t, x=105+t*595, y=190-Math.sin(Math.PI*t)*161;
  ctx.fillStyle=blend([231,181,128],[86,108,123],late);ctx.fillRect(0,0,800,330);
  ctx.fillStyle=blend([255,219,143],[248,162,97],late);ctx.beginPath();ctx.arc(x,y,44,0,tau);ctx.fill();
  for(let layer=0;layer<3;layer++){
    const profile=pos=>154+layer*44+Math.sin(pos/(130-layer*18)+layer*.7+t*(.95+layer*.9))*37+Math.cos(pos/62+t*(1+layer))*(8+layer*3);
    const fills=['#a56753','#764c43','#323b39'],inks=['#764d47','#513b37','#b3aa83'];
    ctx.beginPath();ctx.moveTo(0,330);
    for(let px=0;px<=800;px+=4)ctx.lineTo(px,profile(px));
    ctx.lineTo(800,330);ctx.closePath();ctx.fillStyle=fills[layer];ctx.fill();
    ctx.save();ctx.clip();ctx.lineWidth=1;ctx.strokeStyle=inks[layer];ctx.globalAlpha=layer===2?.6:.67;
    for(let n=0;n<35;n++){
      ctx.beginPath();
      for(let px=0;px<=800;px+=5){const py=profile(px)+n*(4+layer)+Math.sin(px/110+n*.21+t)*n*.45;if(!px)ctx.moveTo(px,py);else ctx.lineTo(px,py);}
      ctx.stroke();
    }
    ctx.restore();
  }
  range.value=time.toFixed(1);range.setAttribute('aria-valuetext',Math.round(time*10)/10+'초, 전체 8초');
  document.querySelector('#time').textContent=time.toFixed(1)+'초';
  document.querySelector('#frame').textContent='F '+String(Math.round(time*24)).padStart(3,'0');
}
function pause(){cancelAnimationFrame(raf);raf=0;play.textContent='▶ 재생';play.setAttribute('aria-label','재생');}
function tick(now){time=Math.min(8,(now-origin)/1000);draw();if(time<8)raf=requestAnimationFrame(tick);else pause();}
play.onclick=()=>{if(raf){pause();return;}if(time>=8)time=0;origin=performance.now()-time*1000;play.textContent='Ⅱ 정지';play.setAttribute('aria-label','일시 정지');raf=requestAnimationFrame(tick);};
range.addEventListener('pointerdown',pause);range.addEventListener('input',()=>{pause();time=Number(range.value);draw();});
document.addEventListener('visibilitychange',()=>{if(document.hidden)pause();});
new ResizeObserver(draw).observe(canvas);draw();
</script></body></html>
```

