Button Hold event

Is there a way to catch button hold event and do an operation repeatedly for every second.
Currently I have an increment button and on click I increment the value by x. When the user holds down the increment button I would like to increment in multiples.

Thanks,
Sankaranarayanan MG

Check this out - http://roblouie.com/article/198/using-gestures-in-the-ionic-2-beta

1 Like

Any news on hold events in Ionic 2? :sleepy:

1 Like

Actually, using (press)="press()" for starting and (touchend)="touchend()" for stopping, will do the trick…

2 Likes

thank you .you made my day…

:slight_smile: i know that AHAH

thanks for your help

Hi,Andrea
How can i search all events in ionic ?

I was searching all over the place for such feature to repeat fire a method when holding a button. Here what I found, hope it become useful for someone else looking for something similar.

<button (press)="holdCount()" (touchend)="endCount()" (tap)='remove()'>
</button>

holdCount(){
    this.timeoutHandler = setInterval(() => {
      ++this.count;
    }, 100);
 }

 endCount(){
   if (this.timeoutHandler) {
    clearTimeout(this.timeoutHandler);
    this.timeoutHandler = null;
  }
 }

Source: https://stackoverflow.com/questions/43071160/how-to-listen-for-a-click-and-hold-in-angular-2