Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

639
Views
Doble toque/doble clic en Angular2 e iónico

Estoy buscando en muchos foros y preguntas, pero nadie parece preguntar cómo hacer doble clic o doble toque en Angular/ionic 2.

En ionic v1 estaba disponible con on-double-tap (ver http://ionicframework.com/docs/api/directive/onDoubleTap/ )

¿Alguien tiene un consejo o algún código para capturar eventos de doble clic en ionic 2/angular 2?

¿Quizás a través de HammerJS?

Muchos gracias ! Luis :)

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Entonces, después de 1-2 horas, era obvio que no necesita capturar eventos de doble clic con Ionic, sino con JavaScript puro: dblclick()

Entonces, en Angular 2 sería: (dblclick)="myFunction()" y eso es todo!

Aquí encontrará otros eventos para JavaScript .

about 4 years ago · Santiago Trujillo Report

0

archivo html

 <button (tap)="tapEvent()">Tap Me!</button>

archivo ts

 let count : number = 0; tapEvent(){ this.count++; setTimeout(() => { if (this.count == 1) { this.count = 0; alert('Single Tap'); }if(this.count > 1){ this.count = 0; alert('Double Tap'); } }, 250);

}

about 4 years ago · Santiago Trujillo Report

0

Para capturar el evento de doble clic, se puede usar lo siguiente:

 (dblclick)="clickFunction()"

Si queremos activar una función al hacer clic y otra función al hacer doble clic, podemos usar lo siguiente:

 <button (click)="simpleClickFunction()" (dblclick)="doubleClickFunction()">click me!</button>

Sin embargo, la función simpleClickFunction también se llamará cuando se doubleClickFunction . Para evitar que suceda, setTimeout puede ayudar de la siguiente manera:

html template

 <button (click)="simpleClickFunction()" (dblclick)="doubleClickFunction()">click me!</button>

Component

 simpleClickFunction(): void{ this.timer = 0; this.preventSimpleClick = false; let delay = 200; this.timer = setTimeout(() => { if(!this.preventSimpleClick){ //whatever you want with simple click go here console.log("simple click"); } }, delay); } doubleClickFunction(): void{ this.preventSimpleClick = true; clearTimeout(this.timer); //whatever you want with double click go here console.log("double click"); }
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!