Interactions

Press

Normalizes the press event across different browsers and devices.

Import

Import the Press primitives from ng-primitives/interactions.

import { NgpPress } from 'ng-primitives/interactions';

Usage

Assemble the press directives in your template.

<div
  ngpPress
  (ngpPressStart)="onPressStart()"
  (ngpPressEnd)="onPressEnd()"
  (ngpPressChange)="onPressChange($event)"
></div>

API Reference

The following directives are available to import from the ng-primitives/interactions package:

NgpPress

The ngpPress directive listens for press events on an element. This is particularly useful for supporting press events on touch devices, where press events are not handled consistently.

  • Selector: [ngpPress]
  • Exported As: ngpPress
Event emitted when the press state changes. Whether press events are disabled. Event emitted when the press starts. Event emitted when the press ends.

Data Attributes

Attribute Description Value
data-press Whether the element is being pressed. true | false

Copyright © 2024 Angular Primitives