Popover

For elements with the popover attribute: showPopover(), hidePopover(), togglePopover() and popovertarget buttons are animated; top layer, light dismiss and focus stay native.

Live example

popover="auto"

Esc or a click outside close it, natively and instantly.

popover="manual"

Only the button or a script closes it.

Usage

<button popovertarget="menu">Menu</button>
<div id="menu" popover>…</div>
import { createRenderer, createPopoverFx, inkVeilEffect } from 'webgl-ui'

const renderer = createRenderer()
// 'behind': the veil paints the popover's surface behind its content: it appears from nothing.
createPopoverFx(document.querySelector<HTMLElement>('#menu')!, { renderer, effect: inkVeilEffect, layout: 'behind' })
/* The shader paints the surface: keep it transparent while animating, and say which color to paint. */
[popover] { --fx-cover: 251, 248, 240; }
[popover][data-fx-behind][data-animating] { background: transparent; }
[popover][data-animating] > :not(canvas) { opacity: var(--p, 1); }

Options

OptionTypeDefaultDescription
rendererRenderer | () => RendererrequiredThe shared renderer.
effectEffectDefdissolveEffectAny cover effect.
durationnumber800Opening in ms; closing takes 70%.
layout'host' | 'behind''host'host: a cover over the popover recedes. behind: a veil paints the popover's surface behind its content, so it appears from nothing.
trace(message) => voidnoneDebug hook.

Returns

MemberDescription
showPopover(options?)Native call, synchronous (same errors), then the animation. Also installed on the element.
hidePopover()Animated; the native method runs at the end.
togglePopover(force?)Returns the state it is heading to.
destroy()Restores the native methods and removes the listeners.
debug(){ open, target, running, progress }.

CSS hooks

HookMeaning
[data-animating], --pSet on the popover while animating.
[data-fx-behind]Present with layout: 'behind'.
--fx-coverThe color the shader paints, as r, g, b. Default: the popover background.

Behavior and accessibility

Full table: native parity, popover.