# FloatingPanel 플로팅 패널
하단 고정 플로팅 패널로, 앵커 단위에 스냅합니다(앵커 기하학 / 스냅 변환은
@lh-ui/share/core/floating-panel), 루트 클래스는 lh-floating-panel,
스타일은 share styles/floating-panel에서 옵니다.
<template>
<div class="demo-col" style="gap: 18px; max-width: 480px">
<div class="demo-row" style="gap: 8px; flex-wrap: wrap">
<LhButton size="small" @click="anchorIndex = 0">최저 단위로 접기</LhButton>
<LhButton size="small" @click="anchorIndex = 1">중간 단위</LhButton>
<LhButton size="small" @click="anchorIndex = 2">최고 단위로 펼치기</LhButton>
<LhButton size="small" @click="contentDraggable = !contentDraggable">콘텐츠 드래그 ({{ contentDraggable }})</LhButton>
</div>
<div class="demo-row" style="gap: 8px; flex-wrap: wrap">
<LhButton size="small" @click="safeArea = !safeArea">안전 영역 여백 ({{ safeArea }})</LhButton>
<LhButton size="small" @click="disabled = !disabled">비활성화 ({{ disabled }})</LhButton>
</div>
<span class="demo-note">
단위: {{ anchorIndex }} / 실시간 높이: {{ height }}px (anchors: 60px / 40% / 80% 뷰포트 높이)
</span>
<LhFloatingPanel
:anchors="anchors"
:model-value.sync="anchorIndex"
:content-draggable="contentDraggable"
:safe-area-inset-bottom="safeArea"
:disabled="disabled"
label="필터 패널"
@change="onChange"
@height-change="onHeightChange"
>
<div style="padding: 12px; display: flex; flex-direction: column; gap: 12px">
<p class="demo-note" style="margin: 0">머리 손잡이나 콘텐츠 영역을 끌어 패널 높이를 변경하고, 손을 떼면 가장 가까운 앵커에 스냅합니다.</p>
<p class="demo-note" style="margin: 0">머리 이름 슬롯으로 손잡이를 사용자 정의할 수 있습니다; contentDraggable=false일 때는 머리만 드래그할 수 있습니다.</p>
</div>
</LhFloatingPanel>
</div>
</template>
<script>
export default {
data: () => ({
anchors: [60, '40%', '80%'],
anchorIndex: 1,
contentDraggable: true,
safeArea: true,
disabled: false,
height: 0,
}),
methods: {
onChange(index) {
this.anchorIndex = index
},
onHeightChange(height) {
this.height = Math.round(height)
},
},
}
</script>
# 앵커와 스냅
anchors는 높이 배열입니다: 수치 = px, '40%' 형태의 문자열 = 뷰포트 높이의 백분율;
내부적으로 오름차순 px으로 정규화합니다(normalizeAnchors). 머리 손잡이를 드래그하는 동안
높이는 computeDragHeight로 손을 따라가고(--dragging이 높이 전환을 끔), 손을 떼면
resolveSnapIndex로 가장 가까운 앵커에 스냅하며 change / update:modelValue를 내보냅니다:
<LhFloatingPanel :anchors="[60, '40%', '80%']" @change="onChange" />
# 제어 단위
modelValue는 현재 스냅 단위 인덱스(0부터, 앵커 오름차순 기준)입니다; 제어가 우선합니다 ——
외부 갱신이 내부 단위를 덮어쓰고, 드래그 제출은 이벤트만 내보냅니다(.sync 되돌림 판정):
<LhFloatingPanel :anchors="[60, '40%']" :model-value.sync="index" />
# 드래그 영역과 안전 영역
contentDraggable(기본 true)은 콘텐츠 영역 드래그를 켜고, false일 때는 머리
손잡이만 드래그할 수 있습니다; safeAreaInsetBottom(기본 true)은 하단 안전 영역 여백을
추가합니다(--safe-area 수정자); disabled는 드래그를 비활성화합니다(--disabled 수정자).
머리 이름 슬롯 header는 기본적으로 __handle 손잡이 막대를 렌더링하며, 사용자 정의할 수 있습니다.
# Props
| 프로퍼티 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| anchors | 스냅 높이 배열 (수치 px 또는 '백분율' 문자열) | (number \| string)[] | [60, '40%'] |
| modelValue | 현재 스냅 단위 인덱스 (제어; 미전달 시 기본 최고 단위) | number | — |
| contentDraggable | 콘텐츠 영역 드래그 가능 (false일 때 머리만) | boolean | true |
| safeAreaInsetBottom | 하단 안전 영역 여백 | boolean | true |
| disabled | 드래그 비활성화 | boolean | false |
| label | 접근성 접근 가능한 이름 (미전달 시 기본 '플로팅 패널 i/N 단위' 사용) | string | — |
# Events
| 이벤트 | 설명 | 콜백 매개변수 |
|---|---|---|
| update:modelValue | 단위 변화 (제어 .sync) | anchorIndex: number |
| change | 스냅 단위 변화 | anchorIndex: number |
| heightChange | 패널 높이 변화 (드래그 추종 / 스냅 착지) | height: number |
# Slots
| 슬롯 | 설명 |
|---|---|
| header | 머리 손잡이 영역 (기본 lh-floating-panel__handle 표시 막대 렌더링) |
| default | 패널 콘텐츠 |
# 접근성
루트 요소 role="region" + aria-label(getFloatingPanelAria가 생성하는
'플로팅 패널 i/N 단위', label로 덮어쓰기 가능).
Copyright © 2024-2026 FengMo WenXue