Skip to main content
cngx-src documentation

CngxHoverIntent

DirectivePrimaryv0.1.0WCAG AA

projects/common/interactive/hover-intent/hover-intent.directive.ts

Import#

import { CngxHoverIntent } from '@cngx/common/interactive'

Description#

Debounced hover-intent primitive. Turns raw pointer enter/leave into a boolean signal that flips true only after the pointer has rested on the host for enterDelay ms of continuous hover, and back to false after leaveDelay ms of continuous un-hover.

A pointer that merely passes over the host never fires: the pending timer is cancelled by the opposite event before it elapses. Use it for hover-to-reveal panels, hover-to-prefetch triggers, or any affordance that reads as nervous when it reacts to an instant mouseenter.

The active signal is read-only - it is derived from pointer events and is never consumer-writable, so it is exposed via asReadonly() plus an intentChange output rather than a two-way model(). Pointer-only, no keyboard surface: hover intent is a mouse concept and carries no ARIA.

Hover to reveal

<div cngxHoverIntent #hi="cngxHoverIntent" [enterDelay]="150">
  <span>Card</span>
  @if (hi.active()) { <div class="detail">…</div> }
</div>

Bind the edge

<a cngxHoverIntent (intentChange)="$event && prefetch()">Link</a>

https://cngxjs.github.io/cngx/examples/#/common/interactive/hover-intent/hover-to-reveal https://cngxjs.github.io/cngx/examples/#/common/interactive/hover-intent/hover-to-prefetch

Metadata#

Host#

Index#

Inputs#

enterDelay#number
input()

ms of continuous hover before active settles to true.

default this.defaults?.enterDelay ?? 120
leaveDelay#number
input()

ms of continuous un-hover before active settles back to false.

default this.defaults?.leaveDelay ?? 0

Outputs#

intentChange#boolean
output()

Emitted on every debounced edge: true on settle-in, false on settle-out.

Instance Properties#

active#unknown
Readonly

Debounced hover-intent state. true only after enterDelay ms of continuous hover.

this.intentState.asReadonly()

Methods#

handleEnter#void
Protected
handleLeave#void
Protected

HostListeners#

EventHandler
(pointerenter)pointerenter()
(pointerleave)pointerleave()