Clean up multiselect pulldown pattern
This commit is contained in:
1 parent
23b1c4b47d
commit
905e85a8ea
1 file changed
-24
@@ -502,36 +502,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
demo.dataset.align = 'left';
|
|
||||||
demo.dataset.open = String(nextState);
|
demo.dataset.open = String(nextState);
|
||||||
trigger.setAttribute('aria-expanded', String(nextState));
|
trigger.setAttribute('aria-expanded', String(nextState));
|
||||||
|
|
||||||
if (!nextState) {
|
if (!nextState) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const panel = demo.querySelector('.sg-pulldown-panel');
|
|
||||||
if (!panel) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
demo.dataset.align = 'left';
|
|
||||||
panel.style.left = '0px';
|
|
||||||
panel.style.right = 'auto';
|
|
||||||
|
|
||||||
const initialRect = panel.getBoundingClientRect();
|
|
||||||
let offsetX = 0;
|
|
||||||
const maxRight = window.innerWidth;
|
|
||||||
|
|
||||||
if (initialRect.right > maxRight) {
|
|
||||||
offsetX -= initialRect.right - maxRight;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (initialRect.left + offsetX < 0) {
|
|
||||||
offsetX += 0 - (initialRect.left + offsetX);
|
|
||||||
}
|
|
||||||
|
|
||||||
panel.style.left = `${offsetX}px`;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user