You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/action-document/main.svelte

25 lines
537 B

<script>
let container;
function tooltip(node, text) {
let tooltip = null;
function onVisibilityChange() {
tooltip = document.createElement('div');
tooltip.classList.add('tooltip');
tooltip.textContent = text;
container.appendChild(tooltip);
}
node.addEventListener('visibilitychange', onVisibilityChange);
return {
destroy() {
node.removeEventListener('visibilitychange', onVisibilityChange);
}
}
}
</script>
<svelte:document use:tooltip="{'Perform an Action'}" />
<div bind:this={container} />