Actions
Click Outside
Description
The Click Outside action can be used to detect clicks outside of an element, this can be useful for example when you want to close a modal when the user clicks outside of it.
Usage
<script lang="ts">
import { click_outside, type ClickOutsideParameters } from 'action-archive';
const clickOutsideParameters: ClickOutsideParameters = {
container: document.documentElement
}
</script>
<div use:click_outside={outsideClickParameters} on:aa_click_outside={...} />
Example
API
Parameters
Name | Type | Default | Description |
---|---|---|---|
container | HTMLElement | string | document.bodyElement | Element or query selected element which will act as the container, clicking outside of the container will not trigger an aa_click_outside event. |
disabled | boolean | false | Disables the action. |
Events
Name | Type | Description |
---|---|---|
aa_click_outside | (event: MouseEvent) => void | Emitted when clicking outside of the node and inside of the container. |