Overlay Positioning
Inkio์ ํ์ค๋ฒ/ํ๋กํ UI๋ ๊ณตํต ์ค๋ฒ๋ ์ด ์์ง์ ์ฌ์ฉํฉ๋๋ค.
๋ณด์ฅ ๋ฒ์
- ๋ทฐํฌํธ ๊ฒฝ๊ณ ์ถฉ๋ ์ flip
- ๊ฒฝ๊ณ ๋ฐ๊นฅ์ผ๋ก ๋ฒ์ด๋๋ ๊ฒฝ์ฐ shift(clamp)
- ์คํฌ๋กค/๋ฆฌ์ฌ์ด์ฆ/์๋ฆฌ๋จผํธ ๋ฆฌ์ฌ์ด์ฆ ์ ์๋ ์ฌ๊ณ์ฐ
position: fixed๊ธฐ๋ฐ ๊ณ์ฐ์ผ๋ก inline/inline-block ์ปจํ ์คํธ์์๋ ์์ ์ ๋์
์ฌ์ฉ API
import {
computeOverlayPosition,
autoUpdateOverlayPosition,
} from '@inkio/editor';computeOverlayPosition
ํต์ฌ ์์น ๊ณ์ฐ ํจ์์ ๋๋ค.
const result = computeOverlayPosition({
anchorRect,
floatingRect,
placement: 'top',
align: 'center',
offset: 8,
padding: 8,
flip: true,
shift: true,
});autoUpdateOverlayPosition
์คํฌ๋กค/๋ฆฌ์ฌ์ด์ฆ/ResizeObserver ๊ธฐ๋ฐ ์๋ ์ ๋ฐ์ดํธ ์ ํธ์ ๋๋ค.
const cleanup = autoUpdateOverlayPosition({
update: updatePosition,
elements: [editorElement, popupElement],
});
// unmount ์
cleanup();์ ์ฉ ์ปดํฌ๋ํธ
BubbleMenuFloatingMenuSuggestionPopupCommentComposerBlockHandle๊ธฐ๋ณธ ๋ฉ๋ด
๊ถ์ฅ์ฌํญ
- anchor๋ ๊ฐ๋ฅํ๋ฉด
getBoundingClientRect()๊ธฐ๋ฐ์ผ๋ก ๊ณ์ฐ - ํฌํธ๋ก ๋ ๋๋งํ๋ ์ค๋ฒ๋ ์ด๋
position: fixed์ฌ์ฉ z-index๋ ํ ํฐ(--inkio-layer-*)์ ํตํด ์ผ๊ด๋๊ฒ ๊ด๋ฆฌ
Last updated on