refac
This commit is contained in:
1 parent
db5c092299
commit
bab71ed08b
1 file changed
+10
-1
@@ -34,6 +34,9 @@
|
|||||||
/** Alignment of the dropdown: 'start' | 'end' */
|
/** Alignment of the dropdown: 'start' | 'end' */
|
||||||
export let align = 'start';
|
export let align = 'start';
|
||||||
|
|
||||||
|
/** Side to open on: 'bottom' | 'top' */
|
||||||
|
export let side = 'bottom';
|
||||||
|
|
||||||
/** Callback when dropdown closes */
|
/** Callback when dropdown closes */
|
||||||
export let onClose: () => void = () => {};
|
export let onClose: () => void = () => {};
|
||||||
|
|
||||||
@@ -62,8 +65,14 @@
|
|||||||
|
|
||||||
contentEl.style.position = 'fixed';
|
contentEl.style.position = 'fixed';
|
||||||
contentEl.style.zIndex = '9999';
|
contentEl.style.zIndex = '9999';
|
||||||
contentEl.style.top = `${rect.bottom + 4}px`;
|
|
||||||
contentEl.style.minWidth = `${rect.width}px`;
|
contentEl.style.minWidth = `${rect.width}px`;
|
||||||
|
if (side === 'top') {
|
||||||
|
contentEl.style.bottom = `${window.innerHeight - rect.top + 4}px`;
|
||||||
|
contentEl.style.top = 'auto';
|
||||||
|
} else {
|
||||||
|
contentEl.style.top = `${rect.bottom + 4}px`;
|
||||||
|
contentEl.style.bottom = 'auto';
|
||||||
|
}
|
||||||
|
|
||||||
if (align === 'end') {
|
if (align === 'end') {
|
||||||
contentEl.style.right = `${window.innerWidth - rect.right}px`;
|
contentEl.style.right = `${window.innerWidth - rect.right}px`;
|
||||||
|
|||||||
Reference in new issue
Block a user