# 선반에서 노트를 골라 샘플 열기

선반의 책등을 누르면 선택한 노트가 개별 샘플로 이어집니다. 이 패턴을 적용하면 사용자는 방금 고른 항목을 눈으로 따라가며 새 화면에서 바로 조작할 수 있습니다. 노트 세 권의 표지와 샘플은 UI Motion Lab을 위해 제작했습니다.

## 원본에서 본 동작

Interaction Library는 한 화면 안에 책등 11개를 나란히 세웁니다. 책을 선택하면 개별 인터랙션을 살펴볼 수 있고, 목록 보기와 선반으로 돌아가는 제어가 있습니다. [Interaction Library](https://library.jjangik.kr/)

## 이 예제의 화면과 동작

- 종이색 바탕 위에 빛이 비치는 어두운 서가를 놓습니다. 왼쪽부터 짙은 녹색 드로어, 녹슨 주홍색 스프링, 모래색 선 그리기 노트가 서 있습니다. 책등에는 천 결, 겹줄과 서로 다른 표식이 있고 각 권의 높이와 기울기가 다릅니다.
- 책등을 누르거나 목록에서 제목을 고르면 선택한 노트가 원래 자리에서 독자의 앞으로 이동합니다. 표지가 먼저 정면을 향한 뒤 펼쳐집니다. 왼쪽 면에 제목과 설명이, 오른쪽 면에 한 번 자동 시연되는 샘플과 조작 버튼이 나타납니다.
- 책을 꺼낼 때는 Popmotion 스프링의 이동을 30fps 기준 15프레임에 맞춥니다. 감쇠 19, 강성 160, 질량 0.85입니다. 0~8프레임에 표지가 −63도에서 정면으로 돌아오고, 14~23프레임에 −94도로 펼쳐집니다. 양쪽 면은 12~24프레임에 드러납니다. 전체 800ms는 이 예제에서 정한 시간입니다.
- 오른쪽의 ‘크게 보기’를 누르면 같은 상태의 샘플이 확대됩니다. 드로어 노트의 버튼은 미니 패널을 열고 닫습니다. 스프링 노트에서는 작은 공을 다시 튕길 수 있습니다. 선 그리기 노트에서는 경로를 다시 그립니다. 확대 상태의 Esc는 노트로, 노트의 Esc와 ‘닫기’는 이전 선반 또는 목록의 같은 버튼으로 돌아갑니다.
- 좁은 화면에서는 세 권을 한 줄로 유지하고 책을 펼쳤을 때 왼쪽 43%에 설명, 오른쪽 57%에 샘플을 놓습니다. 확대하면 샘플이 가로폭을 전부 사용합니다. 키보드의 Tab, Enter, Space, Escape를 지원합니다. 기기의 ‘동작 줄이기’ 또는 URL의 `?reduce=1`을 사용하면 바로 도착 상태를 보여줍니다. `?embed=1`은 갤러리 안에서 중복되는 전역 머리글을 접습니다.

## 확인하는 방법

가운데 책등을 눌러 스프링 샘플을 재생하고 Esc로 돌아갑니다. ‘목록 보기’를 켠 뒤 세 번째 제목을 선택해 ‘다시 그리기’를 누릅니다. 모바일과 동작 줄이기 설정에서도 같은 조작을 확인할 수 있습니다.

## 그대로 보낼 요청

> 세 가지 인터랙션 샘플을 노트 선반에 놓아줘. 책등이나 텍스트 목록의 제목을 고르면 선택한 노트가 이동해 펼쳐지고, 바로 샘플을 조작하게 해줘. 키보드로 닫으면 선택했던 노트에 포커스를 돌려줘. 동작 줄이기에서는 이동과 회전을 생략해줘.

[실행 데모 및 단일 HTML](../examples/sample-shelf/index.html)

## 모션 출처와 사용 조건

beamnxw의 시연에서는 Remotion으로 장면을 프레임 단위로 구성했습니다. 이 예제에서도 표지 회전과 내지가 나타나는 시점을 프레임으로 지정합니다. [시연 원문](https://x.com/beamnxw/status/2108616740846420354)

웹에서 책을 클릭하고 다시 조작하는 동작에는 Popmotion 11.0.5의 스프링과 수치 보간을 사용합니다. 시간은 브라우저의 재생 시각에 맞추므로 화면 주사율이 달라도 열리는 데 걸리는 시간은 같습니다. 노트와 각 샘플은 이 예제를 위해 만들었습니다. HTML에는 재배포할 때 함께 전달할 MIT 저작권 고지와 라이선스가 들어 있습니다. [Popmotion 고정 소스](https://github.com/Popmotion/popmotion/tree/adf681efd8568ada018ce68082dbd585f25c4c7d/packages/popmotion) · [MIT 라이선스](https://github.com/Popmotion/popmotion/blob/adf681efd8568ada018ce68082dbd585f25c4c7d/packages/popmotion/LICENSE.md)

## 실행 코드

아래 HTML을 한 파일로 저장해 브라우저에서 여세요. 필요한 스타일과 프레임 계산 코드가 모두 들어 있습니다.

<!-- standalone-example -->

```html
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>샘플 선반 · UI Motion Lab</title>
<script>
  const settings = new URLSearchParams(location.search)
  document.documentElement.classList.toggle('embed', settings.get('embed') === '1')
  document.documentElement.classList.toggle('reduce', settings.get('reduce') === '1')
</script>
<style>
  :root {
    color-scheme: light;
    --paper:#f6f5f0; --ink:#24242b; --violet:#7255db; --lilac:#e4def7;
    --orange:#fd734e; --mint:#d3e7dd; --line:#d7d5cc;
    font-family:Inter,Pretendard,"Apple SD Gothic Neo","Malgun Gothic",sans-serif;
    background:var(--paper); color:var(--ink);
  }
  * {box-sizing:border-box}
  body {margin:0}
  button {color:inherit;font:inherit;cursor:pointer}
  button:focus-visible {outline:3px solid #4c34ad;outline-offset:3px}
  [hidden] {display:none!important}
  .brand {display:flex;align-items:center;gap:9px;font-size:14px;font-weight:720;border-bottom:1px solid var(--line);padding:14px clamp(16px,5vw,55px)}
  .logo {position:relative;display:inline-grid;place-content:center;background:var(--ink);color:white;width:32px;height:32px;border-radius:8px;font-size:26px;line-height:1;letter-spacing:-2px}
  .logo i {position:absolute;right:1px;top:0;color:var(--orange);font:700 12px/1 sans-serif}
  .embed .brand {display:none}
  main {margin:0 auto;max-width:850px;padding:clamp(16px,4.5vw,50px)}
  .heading {display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:16px}
  h1,h2,p {margin:0}
  h1 {font-size:clamp(22px,4vw,37px);letter-spacing:-.065em}
  .quiet {border:1px solid #a6a49e;background:transparent;padding:8px 13px;border-radius:999px;font-size:12px;font-weight:650}
  .shelf {
    display:flex;align-items:flex-end;justify-content:center;gap:clamp(3px,.6vw,7px);
    min-height:clamp(175px,41vh,360px);padding:18px 12px 0;
    border-bottom:9px solid #4c3328;background:
      linear-gradient(0deg,#231f1e80,transparent 14%),
      linear-gradient(118deg,transparent 4%,#f7ddaa24 27%,transparent 58%),
      radial-gradient(ellipse at 43% 25%,#736657,#393630 85%);
    box-shadow:inset 0 8px 18px #211a1a4f,0 2px #231b18,0 7px 8px #352d251a;overflow:visible;
  }
  .shelf button {align-self:flex-end;display:flex;align-items:center;flex-direction:column;justify-content:space-between;position:relative;
    width:clamp(55px,10vw,87px);height:clamp(147px,30vh,250px);padding:13px 7px 15px;border:1px solid rgba(36,36,43,.45);
    border-radius:5px 7px 1px 2px;transform-origin:center bottom;transform:rotate(var(--lean,0deg));
    box-shadow:inset 1px 0 #ffffff44,inset -3px 0 #0004,5px 2px 5px #19140e66;
    transition:transform .24s cubic-bezier(.2,.7,.22,1)}
  .shelf button:nth-child(2) {height:clamp(160px,33vh,275px)}
  .shelf button:nth-child(3) {height:clamp(136px,27vh,230px)}
  .drawer {--cover:#222c29;--type:#f0e4c5;--lean:-3deg}
  .spring {--cover:#ae4532;--type:#ffebca}
  .draw {--cover:#cfbf92;--type:#322a1b;--lean:5deg}
  .shelf button,.front {background:
    linear-gradient(90deg,#130e0c60,transparent 12%,#ffffff12 26%,transparent 84%,#120d0c36),
    repeating-linear-gradient(0deg,transparent 0 2px,#ffffff0a 2px 3px),
    repeating-linear-gradient(90deg,transparent 0 2px,#00000009 2px 3px),
    var(--cover);color:var(--type)}
  .shelf button::before {content:"";position:absolute;inset:7px 5px 6px;border-block:3px double currentColor;opacity:.58;pointer-events:none}
  .spine-title {writing-mode:vertical-rl;font-size:clamp(15px,2.4vw,20px);font-weight:720;letter-spacing:.07em}
  .symbol {display:inline-grid;place-content:center;width:1.3em;height:1.3em;line-height:1;font-family:Arial,sans-serif;font-size:23px;font-weight:bold}
  .shelf button:focus-visible {transform:translateY(-5px) scale(1.035)}
  @media (hover:hover) {.shelf button:hover {transform:translateY(-5px) scale(1.035)}}
  .shelf button[aria-expanded=true] {visibility:hidden}
  .list {display:grid;border-top:1px solid var(--ink)}
  .list button {text-align:left;display:flex;align-items:center;gap:12px;border:0;border-bottom:1px solid var(--line);padding:14px 4px;background:transparent;font-weight:650}
  .list .symbol {background:var(--cover);color:var(--type);border-radius:3px;font-size:17px;width:32px;height:36px}
  .list .arrow {margin-left:auto}
  dialog {position:fixed;inset:0;margin:0;padding:8px 13px;color:var(--ink);border:0;background:transparent;width:100%;height:100%;max-width:none;max-height:none;overflow:auto}
  dialog[open] {display:grid;place-items:center}
  .sheet {--reveal:1;width:min(620px,100%);position:relative;isolation:isolate}
  .sheet::before {content:"";inset:0;position:absolute;z-index:-1;border:1px solid var(--ink);border-radius:6px;background:var(--paper);box-shadow:0 12px 48px #24242b3d;opacity:var(--reveal)}
  dialog::backdrop {background:rgba(36,36,43,.28)}
  .detail-head {display:flex;align-items:center;justify-content:space-between;padding:10px 14px;border-bottom:1px solid var(--line);font-size:12px;font-weight:650}
  .note {display:grid;grid-template-columns:1fr 1fr;align-items:stretch;padding:clamp(10px,2.3vw,18px)}
  .binding {position:relative;min-height:150px;perspective:700px}
  .paper,.flight {position:absolute;inset:0}
  .paper {display:flex;flex-direction:column;justify-content:center;gap:9px;padding:clamp(10px,2.8vw,26px);border-right:1px solid #bbb8af;background:linear-gradient(to left,#d8d5ca,#efece1 7%,#f5f2e8 95%);border-radius:3px;opacity:var(--reveal)}
  .paper p {font-size:clamp(11px,1.8vw,14px);line-height:1.6;word-break:keep-all}
  .flight {transform-origin:top left;perspective:650px;pointer-events:none}
  .front {display:grid;place-items:center;width:100%;height:100%;border:1px solid #39393969;border-radius:3px 6px 4px 2px;transform-origin:left center;backface-visibility:hidden}
  .front .symbol {font-size:clamp(27px,5vw,43px)}
  .content {min-width:0;display:flex;flex-direction:column;align-items:stretch;justify-content:center;padding:clamp(10px,2.8vw,26px);background:linear-gradient(to right,#e4e0d5,#f9f7f0 6%)}
  .zoom {align-self:flex-end;border:0;padding:2px 0;background:none;text-decoration:underline;text-underline-offset:3px;font-size:11px}
  dialog.zoomed .binding {display:none}
  dialog.zoomed .note {grid-template-columns:1fr}
  dialog.zoomed .content {background:transparent}
  dialog.zoomed .demo {height:clamp(60px,29vh,190px)}
  h2 {font-size:clamp(18px,3.8vw,29px);letter-spacing:-.055em}
  .demo {margin:10px 0;position:relative;overflow:hidden;display:grid;place-items:center;height:clamp(54px,12vh,92px);border-radius:5px;background:#e8e6de}
  .interact {border:0;border-radius:999px;background:var(--ink);color:white;padding:8px 14px;font-size:12px;font-weight:650;min-height:34px}
  .mini-drawer {position:absolute;right:0;inset-block:0;width:55%;border-left:1px solid var(--ink);background:var(--lilac);transform:translateX(100%);display:grid;align-content:center;gap:6px;padding-inline:12px}
  .mini-drawer i {display:block;height:3px;background:#63588d}
  .mini-drawer i:last-child {width:62%}
  .drawer-base {width:62%;height:38%;border:1px solid #96938a;border-radius:4px}
  .track {width:72%;height:2px;background:#aaa59b;position:relative}
  .ball {position:absolute;display:block;width:21px;height:21px;border-radius:50%;background:var(--orange);border:1px solid var(--ink);top:50%;left:0;transform:translate(-50%,-50%)}
  .example[data-example="spring"] .demo {background:linear-gradient(#ede9dc 68%,#e3dece 69%,#f5f1e6)}
  .track {height:1px;background:#867c68;box-shadow:0 1px #ffffff94}
  .ball {width:23px;height:23px;border:1px solid #8c382b;background:radial-gradient(circle at 30% 25%,#fbbd87,#c05a3a 43%,#773828 92%);box-shadow:3px 5px 5px -3px #482b1e99}
  .demo svg {width:80%;height:80%;fill:none;stroke:var(--ink);stroke-width:4;stroke-linecap:round;stroke-linejoin:round}
  .demo svg path {stroke-dasharray:1;stroke-dashoffset:0}
  .sr {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
  @media(max-width:420px) {.note {grid-template-columns:43% 57%;padding:8px}.binding {min-height:120px}.detail-head {padding:8px 12px}.heading {margin-bottom:9px}}
  @media(max-height:320px) {main {padding:10px 14px}.heading {margin-bottom:6px}h1 {font-size:19px}.shelf {min-height:115px;padding-top:7px}.shelf button,.shelf button:nth-child(2),.shelf button:nth-child(3) {height:95px;padding:6px}.shelf button:nth-child(2){height:105px}.spine-title {font-size:12px}.symbol {font-size:15px}.note {padding:9px 14px}.binding {min-height:85px}.detail-head {padding:4px 12px}.demo {height:43px;margin:5px 0}.brand {padding:5px 14px}}
  @media(prefers-reduced-motion:reduce) {.shelf button {transition:none!important;transform:none!important}}
  .reduce .shelf button {transition:none!important;transform:none!important}
</style>
</head>
<body>
<header class="brand"><span class="logo" aria-hidden="true">m<i>↗</i></span> UI Motion Lab</header>
<main>
  <div class="heading"><h1>샘플 선반</h1><button type="button" class="quiet" id="view">목록 보기</button></div>
  <div class="shelf" id="shelf" role="group" aria-label="샘플 노트"></div>
  <div class="list" id="list" role="group" aria-label="샘플 목록" hidden></div>
  <noscript>샘플 선반을 사용하려면 브라우저에서 JavaScript를 켜세요.</noscript>
</main>
<dialog id="detail" aria-labelledby="sample-title">
  <div class="sheet">
  <div class="detail-head"><span id="detail-label">샘플 노트</span><button type="button" class="quiet" id="close" autofocus>닫기</button></div>
  <div class="note">
    <div class="binding" id="binding"><div class="paper"><h2 id="sample-title"></h2><p id="description"></p></div><div class="flight" aria-hidden="true"><div class="front"><span class="symbol"></span></div></div></div>
    <div class="content">
      <button type="button" class="zoom" id="zoom" aria-pressed="false">크게 보기</button>
      <section class="example" data-example="drawer">
        <div class="demo" aria-hidden="true"><span class="drawer-base"></span><div class="mini-drawer"><i></i><i></i></div></div>
        <button type="button" class="interact" id="drawer-action" aria-pressed="false">패널 열기</button>
      </section>
      <section class="example" data-example="spring" hidden>
        <div class="demo" aria-hidden="true"><div class="track"><span class="ball"></span></div></div>
        <button type="button" class="interact" id="spring-action">공 튕기기</button>
      </section>
      <section class="example" data-example="draw" hidden>
        <div class="demo" aria-hidden="true"><svg viewBox="0 0 180 68"><path pathLength="1" d="M8 56 C 32 56 36 11 59 13 S 86 69 105 47 S 132 5 148 21 Q 160 32 172 15"/></svg></div>
        <button type="button" class="interact" id="draw-action">다시 그리기</button>
      </section>
      <span role="status" class="sr" id="status"></span>
    </div>
  </div>
  </div>
</dialog>
<script>/*! Popmotion 11.0.5 · https://github.com/Popmotion/popmotion/tree/adf681efd8568ada018ce68082dbd585f25c4c7d

The MIT License (MIT)

Copyright © 2019 Framer BV

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

hey-listen 1.0.8 · https://github.com/Popmotion/hey-listen

MIT License

Copyright (c) 2018 Popmotion

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
var MotionLabFrames=(()=>{var R=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var _=(e,n)=>{for(var t in n)R(e,t,{get:n[t],enumerable:!0})},j=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of K(n))!L.call(e,o)&&o!==t&&R(e,o,{get:()=>n[o],enumerable:!(r=B(n,o))||r.enumerable});return e};var z=e=>j(R({},"__esModule",{value:!0}),e);var Z={};_(Z,{interpolate:()=>Y,spring:()=>X});var q=function(){};var O=(e,n,t)=>Math.min(Math.max(t,e),n);var w=.001,G=.01,F=10,I=.05,C=1;function T({duration:e=800,bounce:n=.25,velocity:t=0,mass:r=1}){let o,c;q(e<=F*1e3,"Spring duration must be 10 seconds or less");let i=1-n;i=O(I,C,i),e=O(G,F,e/1e3),i<1?(o=s=>{let g=s*i,p=g*e,M=g-t,d=S(s,i),v=Math.exp(-p);return w-M/d*v},c=s=>{let p=s*i*e,M=p*t+t,d=Math.pow(i,2)*Math.pow(s,2)*e,v=Math.exp(-p),b=S(Math.pow(s,2),i);return(-o(s)+w>0?-1:1)*((M-d)*v)/b}):(o=s=>{let g=Math.exp(-s*e),p=(s-t)*e+1;return-w+g*p},c=s=>{let g=Math.exp(-s*e),p=(t-s)*(e*e);return g*p});let x=5/e,f=J(o,c,x);if(e=e*1e3,isNaN(f))return{stiffness:100,damping:10,duration:e};{let s=Math.pow(f,2)*r;return{stiffness:s,damping:i*2*Math.sqrt(r*s),duration:e}}}var H=12;function J(e,n,t){let r=t;for(let o=1;o<H;o++)r=r-e(r)/n(r);return r}function S(e,n){return e*Math.sqrt(1-n*n)}var Q=["duration","bounce"],U=["stiffness","damping","mass"];function k(e,n){return n.some(t=>e[t]!==void 0)}function W(e){let n={velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1,...e};if(!k(e,U)&&k(e,Q)){let t=T(e);n={...n,...t,velocity:0,mass:1},n.isResolvedFromDuration=!0}return n}function D({from:e=0,to:n=1,restSpeed:t=2,restDelta:r,...o}){let c={done:!1,value:e},{stiffness:i,damping:x,mass:f,velocity:s,duration:g,isResolvedFromDuration:p}=W(o),M=V,d=V;function v(){let b=s?-(s/1e3):0,l=n-e,m=x/(2*Math.sqrt(i*f)),u=Math.sqrt(i/f)/1e3;if(r===void 0&&(r=Math.min(Math.abs(n-e)/100,.4)),m<1){let a=S(u,m);M=h=>{let y=Math.exp(-m*u*h);return n-y*((b+m*u*l)/a*Math.sin(a*h)+l*Math.cos(a*h))},d=h=>{let y=Math.exp(-m*u*h);return m*u*y*(Math.sin(a*h)*(b+m*u*l)/a+l*Math.cos(a*h))-y*(Math.cos(a*h)*(b+m*u*l)-a*l*Math.sin(a*h))}}else if(m===1)M=a=>n-Math.exp(-u*a)*(l+(b+u*l)*a);else{let a=u*Math.sqrt(m*m-1);M=h=>{let y=Math.exp(-m*u*h),A=Math.min(a*h,300);return n-y*((b+m*u*l)*Math.sinh(A)+a*l*Math.cosh(A))/a}}}return v(),{next:b=>{let l=M(b);if(p)c.done=b>=g;else{let m=d(b)*1e3,u=Math.abs(m)<=t,a=Math.abs(n-l)<=r;c.done=u&&a}return c.value=c.done?n:l,c},flipTarget:()=>{s=-s,[e,n]=[n,e],v()}}}D.needsInterpolation=(e,n)=>typeof e=="string"||typeof n=="string";var V=e=>0;var N=(e,n,t)=>-t*e+t*n+e;var P=(e,n,t)=>{let r=n-e;return r===0?1:(t-e)/r};var E=new Map;function X({fps:e,frame:n,durationInFrames:t,config:r={}}){if(n<=0)return 0;if(t!==void 0&&n>=t)return 1;let{mass:o=1,stiffness:c=100,damping:i=10}=r,x=[o,c,i].join("/"),f=E.get(x);if(!f){let g=D({from:0,to:1,mass:o,stiffness:c,damping:i,restSpeed:.012,restDelta:.002}),p=0;for(;p<1e4&&!g.next(p).done;)p+=8;f={curve:g,settledAt:p},E.set(x,f)}let s=t===void 0?n*1e3/e:n*f.settledAt/t;return f.curve.next(s).value}function Y(e,n,t,r={}){let o=n.length-1;if(r.extrapolateLeft==="clamp"&&e<=n[0])return t[0];if(r.extrapolateRight==="clamp"&&e>=n[o])return t[o];let c=n.findIndex((x,f)=>f>0&&x>=e),i=c<0?o:c;return N(t[i-1],t[i],P(n[i-1],n[i],e))}return z(Z);})();</script>
<script>
  const samples = [
    {id:'drawer', title:'드로어', mark:'▤',description:'화면의 오른쪽 가장자리에서 패널을 꺼냅니다.'},
    {id:'spring', title:'스프링', mark:'●',description:'공이 목표 지점을 살짝 지나쳤다가 제자리에 멈춥니다.'},
    {id:'draw', title:'선 그리기', mark:'∿',description:'펜으로 그리듯 곡선을 처음부터 끝까지 따라갑니다.'}
  ]
  const byId = (id) => document.getElementById(id)
  const dialog = byId('detail')
  const binding = byId('binding')
  const flight = binding.querySelector('.flight')
  const cover = binding.querySelector('.front')
  const content = dialog.querySelector('.content')
  const reduced = matchMedia('(prefers-reduced-motion: reduce)')
  const frames = window.MotionLabFrames
  const clamp = {extrapolateLeft:'clamp',extrapolateRight:'clamp'}
  const requests = {entry:0,sample:0}
  let origin = null
  let drawerOpen = false
  let drawerPosition = 0
  let ballRight = false
  let touched = false

  function play(channel, duration, paint) {
    cancelAnimationFrame(requests[channel])
    if (settings.get('reduce') === '1' || reduced.matches) {
      paint(duration)
      return
    }
    const start = performance.now()
    paint(0)
    function tick(now) {
      const frame = Math.max(0,Math.min((now - start) * 30 / 1000,duration))
      paint(frame)
      if (frame < duration) requests[channel] = requestAnimationFrame(tick)
    }
    requests[channel] = requestAnimationFrame(tick)
  }
  function openNote(button, sample) {
    if (dialog.open) return
    origin = button
    touched = false
    const source = (button.closest('#list') ? button.querySelector('.symbol') : button).getBoundingClientRect()
    button.setAttribute('aria-expanded','true')
    binding.className = 'binding ' + sample.id
    cover.querySelector('.symbol').textContent = sample.mark
    byId('sample-title').textContent = sample.title
    byId('description').textContent = sample.description
    byId('detail-label').textContent = '샘플 노트'
    byId('status').textContent = ''
    dialog.querySelectorAll('[data-example]').forEach(section => {
      section.hidden = section.dataset.example !== sample.id
    })
    dialog.showModal()
    const dest = binding.getBoundingClientRect()
    let previewStarted = false
    play('entry',24,frame => {
      const position = frame >= 15 ? 1 : frames.spring({fps:30,frame,durationInFrames:15,config:{mass:.85,damping:19,stiffness:160}})
      const distance = 1 - position
      const dx = (source.x - dest.x) * distance
      const dy = (source.y - dest.y) * distance
      const sx = 1 + (source.width / dest.width - 1) * distance
      const sy = 1 + (source.height / dest.height - 1) * distance
      flight.style.transform = 'translate('+dx+'px,'+dy+'px) scale('+sx+','+sy+')'
      const angle = frames.interpolate(frame,[0,8,14,23],[-63,0,0,-94],clamp)
      cover.style.transform = 'rotateY('+angle+'deg)'
      const reveal = frames.interpolate(frame,[12,24],[0,1],clamp)
      dialog.querySelector('.sheet').style.setProperty('--reveal',reveal)
      dialog.querySelector('.detail-head').style.opacity = reveal
      content.style.opacity = reveal
      content.style.transform = 'translateY('+((1-reveal)*6)+'px)'
      if (!previewStarted && frame >= 15 && !touched) {
        previewStarted = true
        preview(sample.id)
      }
    })
  }
  function noteButton(sample,isList) {
    const button = document.createElement('button')
    button.type = 'button'
    button.className = sample.id
    button.setAttribute('aria-haspopup','dialog')
    button.setAttribute('aria-expanded','false')
    button.setAttribute('aria-controls','detail')
    const mark = document.createElement('span')
    mark.className = 'symbol'
    mark.setAttribute('aria-hidden','true')
    mark.textContent = sample.mark
    const title = document.createElement('span')
    title.textContent = sample.title
    button.append(mark,title)
    if (isList) {
      const arrow = document.createElement('span')
      arrow.textContent = '↗'
      arrow.className = 'arrow'
      arrow.setAttribute('aria-hidden','true')
      button.append(arrow)
    } else {
      title.className = 'spine-title'
    }
    button.addEventListener('click',() => openNote(button,sample))
    return button
  }
  for (const sample of samples) {
    byId('shelf').append(noteButton(sample,false))
    byId('list').append(noteButton(sample,true))
  }
  byId('view').onclick = () => {
    const toList = byId('list').hidden
    byId('shelf').hidden = toList
    byId('list').hidden = !toList
    byId('view').textContent = toList ? '선반 보기' : '목록 보기'
  }
  byId('close').onclick = () => dialog.close()
  content.addEventListener('click',() => {touched = true},true)
  function showZoom(zoomed) {
    dialog.classList.toggle('zoomed',zoomed)
    byId('zoom').textContent = zoomed ? '노트로 돌아가기' : '크게 보기'
    byId('zoom').setAttribute('aria-pressed',String(zoomed))
    byId('detail-label').textContent = zoomed ? byId('sample-title').textContent : '샘플 노트'
  }
  byId('zoom').onclick = () => showZoom(!dialog.classList.contains('zoomed'))
  dialog.addEventListener('cancel',event => {
    if (dialog.classList.contains('zoomed')) {
      event.preventDefault()
      showZoom(false)
      byId('zoom').focus()
    }
  })
  function preview(id) {
    play('sample',26,frame => {
      if (id === 'drawer') {
        drawerPosition = frames.interpolate(frame,[0,8,16,26],[0,.85,.85,0],clamp)
        dialog.querySelector('.mini-drawer').style.transform = 'translateX('+((1-drawerPosition)*100)+'%)'
      } else if (id === 'spring') {
        const forward = frame < 13
        const progress = frames.spring({fps:30,frame:forward ? frame : frame-13,durationInFrames:13,config:{damping:10,stiffness:130}})
        const travel = frame === 26 ? 0 : 80*(forward ? progress : 1-progress)
        dialog.querySelector('.ball').style.left = travel+'%'
      } else {
        dialog.querySelector('path').style.strokeDashoffset = frames.interpolate(frame,[0,19],[1,0],clamp)
      }
    })
  }
  dialog.addEventListener('close',() => {
    cancelAnimationFrame(requests.entry)
    cancelAnimationFrame(requests.sample)
    drawerOpen = false
    drawerPosition = 0
    ballRight = false
    showZoom(false)
    byId('drawer-action').setAttribute('aria-pressed','false')
    byId('drawer-action').textContent = '패널 열기'
    dialog.querySelector('.mini-drawer').style.transform = ''
    dialog.querySelector('.ball').style.left = ''
    dialog.querySelector('path').style.strokeDashoffset = ''
    if (origin) {
      origin.setAttribute('aria-expanded','false')
      origin.focus({preventScroll:true})
      origin = null
    }
  })
  byId('drawer-action').onclick = () => {
    drawerOpen = !drawerOpen
    const from = drawerPosition
    const to = drawerOpen ? 1 : 0
    byId('drawer-action').textContent = drawerOpen ? '패널 닫기' : '패널 열기'
    byId('drawer-action').setAttribute('aria-pressed',String(drawerOpen))
    play('sample',11,frame => {
      const progress = frame === 11 ? 1 : frames.spring({fps:30,frame,durationInFrames:11,config:{damping:23}})
      drawerPosition = from + (to-from)*progress
      dialog.querySelector('.mini-drawer').style.transform = 'translateX('+((1-drawerPosition)*100)+'%)'
    })
  }
  byId('spring-action').onclick = () => {
    const ball = dialog.querySelector('.ball')
    const from = parseFloat(ball.style.left) || 0
    ballRight = !ballRight
    const to = ballRight ? 100 : 0
    play('sample',24,frame => {
      const progress = frame === 24 ? 1 : frames.spring({fps:30,frame,durationInFrames:24,config:{mass:.8,damping:8,stiffness:135}})
      ball.style.left = (from + (to-from)*progress)+'%'
    })
    byId('status').textContent = ballRight ? '공이 오른쪽으로 이동합니다.' : '공이 왼쪽으로 이동합니다.'
  }
  byId('draw-action').onclick = () => {
    play('sample',19,frame => {
      dialog.querySelector('path').style.strokeDashoffset = frames.interpolate(frame,[0,19],[1,0],clamp)
      if (frame === 19) byId('status').textContent = '선을 완성했습니다.'
      else byId('status').textContent = ''
    })
  }
</script>
</body>
</html>
```
