Skip to main content

Capture

The capture element is used to capture the pointer for future events. This is useful to capture the pointer to eg. a group of buttons to avoid accidentally triggering unrelated elements if the pointer is moved out of bounds.

X Y
B A
<xyba-capture id="capture" capture>
<xyba-button ignore-capture="#capture">X</xyba-button>
<xyba-button ignore-capture="#capture">Y</xyba-button>
</xyba-capture>
<div class="non-captured">
<xyba-button>B</xyba-button>
<xyba-button>A</xyba-button>
</div>

Install

npm install xyba-elements

Importing

Once installed, you can import via xyba-elements.

// Custom Elements
import "xyba-elements/elements/capture/capture.js";

// React
import { Capture } from "xyba-elements/react";

Or import from CDN,

<script src="https://cdn.jsdelivr.net/npm/xyba-elements/dist/cdn/elements/capture/capture.js">

Properties / Attributes

propertyattributetypedefaultdescriptionreadonly
capturecapturebooleanfalseWether the pointer should be captured

CSS Slots

namedescription
The default slot.