Angular Library to handle long mouse clicks event for desktop and long touch events for mobile and tablets
npm install ngx-long-press2
height="256px" width="256px" style="text-align: center;"
src="https://cdn.jsdelivr.net/gh/angular-material-extensions/select-country@master/assets/angular-material-extensions-logo.svg">




src="https://raw.githubusercontent.com/anthonynahas/ngx-long-press2/HEAD/assets/v1.0.0/demo.gif">
If you like this project, support angular-material-extensions
by starring :star: and sharing it :loudspeaker:
View all the directives and components in action at https://anthonynahass.github.io/ngx-long-press2
ngxLongPress2 ---
16.x---
Install peer dependencies
``shell`
npm i -s ngx-long-press2
`typescript
import { NgxLongPress2Module } from 'ngx-long-press2';
@NgModule({
declarations: [AppComponent, ...],
imports: [NgxLongPress2Module, ...],
bootstrap: [AppComponent]
})
export class AppModule {
}
`
Other modules in your application like for lazy loading import NgxLongPress2Module into your feature module:
| option | bind | type | default | description |
|:-------------------|:--------:|:------:|:------------:|:-------------------------------------------------------------------------------------------------|
| minTime | Input() | number | 500 | the minimum time to fire onLongPress event (in ms)Input()
| maxTime | | number | 2000 | the maximum time to fire onReleasePressing event (in ms)Output()
| onLongPress | | EventEmitter | - | emits when the minTime is exceeded Output()
| onLongPressing | | EventEmitter | - | emits when the user is pressing and the time lapsed in ms will be emitted Output()
| onReleasePressing | | EventEmitter | - | emits when the maxTime is exceeded or touchend, mouseup and mouseleave haven been emitted
`html`
ngxLongPress2
[color]="this.timeLapsed1 > 1000? 'primary' : 'warn'"
(onLongPress)="onLongPress()"
(onLongPressing)="onLongPressing($event)"
(onReleasePressing)="onReleasePressing()">
{{ this.timeLapsed1 > 0 ? this.timeLapsed1 + ' ms' : 'PRESS ME'}}
src="https://raw.githubusercontent.com/anthonynahas/ngx-long-press2/HEAD/assets/v1.0.0/demo_full2.png">
`html`
images
Build the library
`bash`
$ npm run build:lib
Serve the demo app
`bash``
$ npm start
---
---
1. Nahaus.de
Are you missing your project or you app? PR me to publish it on the README
---
This project is supported by jetbrains with 1 ALL PRODUCTS PACK OS LICENSE incl. webstorm
---
Copyright (c) 2023 Anthony Nahas. Licensed under the MIT License (MIT)
height="92px" width="92px" style="text-align: center;"
src="https://cdn.jsdelivr.net/gh/angular-material-extensions/select-country@master/assets/badge_made-in-germany.svg">