구이 메뉴

Gooey menu

플로팅 버튼을 누르면 하위 메뉴 항목들이 방울처럼 갈라져 나오는 메뉴. 항목들이 처음엔 메인 버튼과 한 덩어리로 붙어 있다가 거리가 벌어지며 매끄럽게 떨어져 나갑니다.

다른 이름: Blob FAB menuLiquid radial menu
···
html
<svg width="0" height="0"><defs><filter id="goo2"><feGaussianBlur in="SourceGraphic" stdDeviation="8" result="b"/><feColorMatrix in="b" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 26 -12"/></filter></defs></svg>
<div class="gstage">
  <div class="gwrap" id="gwrap">
    <i class="item it1"></i><i class="item it2"></i><i class="item it3"></i><i class="item it4"></i>
    <div class="main"></div>
  </div>
  <span class="icon">+</span>
</div>
css
.gstage{position:relative;width:100%;height:100%;display:grid;place-items:center}
.gwrap{position:relative;filter:url(#goo2);width:1px;height:1px}
.main{position:absolute;top:0;left:0;width:44px;height:44px;margin:-22px 0 0 -22px;border-radius:50%;background:var(--accent)}
.item{position:absolute;top:0;left:0;width:30px;height:30px;margin:-15px 0 0 -15px;border-radius:50%;background:var(--accent-2);
  animation:pop 2.8s ease-in-out infinite}
.it1{animation-delay:0s}.it2{animation-delay:.05s}.it3{animation-delay:.1s}.it4{animation-delay:.15s}
.icon{position:absolute;color:#fff;font:800 20px/1 sans-serif;pointer-events:none}
@keyframes pop{
  0%,14%{transform:translate(0,0) scale(.6)}
  45%,72%{transform:translate(var(--tx),var(--ty)) scale(.82)}
  100%{transform:translate(0,0) scale(.6)}
}
.it1{--tx:-58px;--ty:-14px}
.it2{--tx:-24px;--ty:-52px}
.it3{--tx:24px;--ty:-52px}
.it4{--tx:58px;--ty:-14px}

리퀴드 버튼과 같은 SVG 구이 필터(feGaussianBlur + feColorMatrix)를 메뉴 전체에 적용합니다. 차이는 원이 하나가 아니라 메인 버튼 + 하위 항목 개수만큼의 원이 같은 필터 그룹 안에 있다는 것입니다 — 닫힌 상태에서는 모든 하위 항목이 메인 버튼과 같은 위치(거리 0)에 있어 필터가 전부 하나로 뭉개 보여주고, 열리는 순간 각 항목이 자기 목표 각도·거리로 translate되면서 거리가 벌어질수록 구이 필터의 "이어 붙임" 효과가 사라져 자연스럽게 방울이 떨어져 나가는 것처럼 보입니다.

항목의 목표 위치는 반원 또는 정원 배치로 계산합니다 — 항목 i의 각도를 (전체 펼침 각도 / (항목 수 - 1)) × i로 나누고, 그 각도로 translate(cos(각도) × 반지름, sin(각도) × 반지름)을 구합니다. 메인 버튼에서 멀어지는 것과 동시에 크기가 살짝 작아지게(scale 0.9 정도) 하면 "방금 태어난 방울"이라는 느낌이 강해집니다.

구이 필터가 걸린 영역은 텍스트 렌더링이 흐려질 수 있으므로, 아이콘·라벨은 필터가 걸리지 않는 별도 레이어(필터 그룹 바깥)에 올려 필터가 적용된 배경 도형 위에 z-index로 얹는 방식을 씁니다.

언제 쓰나

모바일 FAB(플로팅 액션 버튼)처럼 항목 3~5개짜리 짧은 메뉴에 브랜드감 있는 열림 연출을 주고 싶을 때 씁니다. 항목이 많거나(6개 이상) 텍스트가 긴 메뉴에는 부적합합니다 — 구이 필터가 블러를 동반해 가독성이 떨어집니다.