Add TriggerV2
This commit is contained in:
24
src/lib/UI/GUI/Portal.svelte
Normal file
24
src/lib/UI/GUI/Portal.svelte
Normal file
@@ -0,0 +1,24 @@
|
||||
<script lang="ts">
|
||||
import { getAllContexts, mount, unmount } from "svelte";
|
||||
//@ts-ignore
|
||||
import PortalConsumer from "./PortalConsumer.svelte";
|
||||
|
||||
interface Props {
|
||||
target?: HTMLElement;
|
||||
children: any;
|
||||
}
|
||||
|
||||
const { target: target = document.body, children }:Props = $props();
|
||||
|
||||
const context = getAllContexts();
|
||||
|
||||
let instance;
|
||||
|
||||
$effect(() => {
|
||||
instance = mount(PortalConsumer, { target, props: { children }, context })
|
||||
|
||||
return () => {
|
||||
unmount(instance);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user