2024-06-24 19:41:44 +02:00
|
|
|
<script lang="ts" context="module">
|
|
|
|
import { writable } from 'svelte/store';
|
|
|
|
|
|
|
|
let currentId = 0;
|
|
|
|
|
|
|
|
function getId() {
|
|
|
|
return currentId++;
|
|
|
|
}
|
|
|
|
|
|
|
|
let lastInitializedId = writable(-1);
|
|
|
|
</script>
|
|
|
|
|
2024-04-11 17:18:21 +02:00
|
|
|
<script lang="ts">
|
|
|
|
import CustomControl from './CustomControl';
|
|
|
|
|
2024-04-17 11:44:37 +02:00
|
|
|
import { map } from '$lib/stores';
|
|
|
|
|
2024-04-11 17:18:21 +02:00
|
|
|
export let position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' = 'top-right';
|
|
|
|
|
|
|
|
let container: HTMLDivElement | null = null;
|
2024-06-24 19:41:44 +02:00
|
|
|
let id = getId();
|
2024-04-11 17:18:21 +02:00
|
|
|
|
2024-06-24 19:41:44 +02:00
|
|
|
$: if ($map && container && $lastInitializedId + 1 === id) {
|
2024-05-04 23:50:27 +02:00
|
|
|
if (position.includes('right')) container.classList.add('float-right');
|
|
|
|
else container.classList.add('float-left');
|
|
|
|
container.classList.remove('hidden');
|
|
|
|
let control = new CustomControl(container);
|
|
|
|
$map.addControl(control, position);
|
2024-06-24 19:41:44 +02:00
|
|
|
lastInitializedId.set(id);
|
2024-04-11 17:18:21 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div
|
|
|
|
bind:this={container}
|
|
|
|
class="{$$props.class ||
|
2024-06-27 15:50:15 +02:00
|
|
|
''} clear-both translate-0 m-[10px] mb-0 last:mb-[10px] pointer-events-auto bg-background rounded shadow-md hidden"
|
2024-04-11 17:18:21 +02:00
|
|
|
>
|
|
|
|
<slot />
|
|
|
|
</div>
|