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

NameTypeDefaultDescription
containerHTMLElement | stringdocument.bodyElementElement or query selected element which will act as the container, clicking outside of the container will not trigger an aa_click_outside event.
disabledbooleanfalseDisables the action.

Events

NameTypeDescription
aa_click_outside(event: MouseEvent) => voidEmitted when clicking outside of the node and inside of the container.