First working POC
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
interface Props {
|
||||
children: any;
|
||||
}
|
||||
|
||||
let { children }: Props = $props();
|
||||
|
||||
/**
|
||||
* Portal action - moves the DOM node to document.body
|
||||
* This escapes any overflow clipping boundaries
|
||||
*/
|
||||
function portal(node: HTMLElement) {
|
||||
const container = document.createElement('div');
|
||||
document.body.appendChild(container);
|
||||
container.appendChild(node);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
if (container.parentNode) {
|
||||
document.body.removeChild(container);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<div use:portal>
|
||||
{@render children()}
|
||||
</div>
|
||||
Reference in New Issue
Block a user