Increment variable faster while pressing button


#1

Any ideas how to do it ? (Ionic 2)

I’ve tried using this article http://roblouie.com/article/198/using-gestures-in-the-ionic-2-beta/ but no success…


#2

How are you incrementing the variable right now before pressing the button?


#3

I have a ion-button using the (click)=“increment();”, where increment() is a function that simples does the this.variable++; Therefore, when someone clicks the button, it increments the value by 1.

My goal is to when someone holds the button, its increase faster than clicking to increments 1 by 1.

Do you think its possible? Any ideas?


#4

This (or something similar) might help: https://medium.com/@amcdnl/angular2-long-press-directive-6e257e991a32


#5

Hey Sujan12, thank you for your time so far.

The press directive you recommended me worked well… but there is a little problem.

When I’m working on my browser(chrome) and the device toolbar is disabled the hold button works without problems(it increments a variable faster), but when I switch to the device toolbar enabled (to change the layout like a cellphone), it doesn’t work anymore: when I hold click on a button, it shows options of the browser like if I were pressing the right button on the page (check screenshot attached). I tried on android simulator and its not working too :frowning: Do you have any ideas how to solve that? maybe avoid this behavior…

Ps.: Tested on a real device and the problem is happening too…


#6

This may as well be a feature of the lib, I have no experience with it unfortunately.