Ionic pinch gesture with debounce/throttle


#1

Hi,

I have pinch gestures working using

import { NavController,Gesture } from 'ionic-angular';

 @ViewChild('pdf') element;
  gesture: Gesture
...
ionViewDidLoad()
  {
     this.gesture = new Gesture(this.element.nativeElement);   
     this.gesture.listen();
     this.gesture.on('pinchout',() => {
         console.log('pinchout');
          this.zoomIn();
         
      });


}

what i am trying to do is to add a debounce/throttle function to the pinchout code so that the zoomin() function doesnt get called 100’s of times.

this.gesture.on('pinchout',() => {
         console.log('pinchout');
          this.zoomIn();
         
      });

tried a whole bunch of different stuff,
currently trying to using undersores debounce function as below, still no pie

this.gesture.on('pinchout',() => {
               
        _.debounce(function(){ 
          console.log('pinchout');
          this.zoomIn();},3000,true);
            
      });

I know this is basically a wrapper around hammer.js, there didn’t seem to be an option there either.

I think that i actually need a throttle function, something that is going to limit the number of times the pinch event is fired.

Does anyone have any ideas ?