Set Timeout for Gesture Hold Event


#1

Hello,

how can pass a custom hold_timeout value to overwrite the default value of 500?

.directive('incrementTemperature', ['$ionicGesture', function($ionicGesture) {
return {
    restrict: 'A',
    link: function($scope, $element, $attr) {

    	// add gesture (#1)
        var holdGesture = $ionicGesture.on('hold', function(e) {
        	// notice
            console.log('Hold-Event');
        }, $element);

        // set timeout (#2)
        holdGesture.options.hold_timeout = 300;

        // debug output (#3)
        console.log(holdGesture);
    }
}

}])

My current “solution” does not work (#2). The custom value appears correctly in the debug log object view (#3) but the hold events occurs at the moment defined in the default value.

I guess, that i have to set the value “on init” (#1). The question is how to do that, i hope you can help me.

Thank you


#2

Hello there,
this works:

            var holdGesture = ionic.Gesture(element[0], {hold_timeout: 250} );
            holdGesture.on('hold', function(event) {
                event.preventDefault();
                event.stopImmediatePropagation();
                event.gesture.srcEvent.preventDefault();
                event.gesture.srcEvent.stopImmediatePropagation();
                $timeout(function(){
                    callback(scope, {event: event});
                });
                return false;
            });

You need to make your own gesture instance, then call ‘on’ on it.