var GESTURE_DIRECTIVES = 'onHold onTap onDoubleTap onTouch onRelease onDrag onDragUp onDragRight onDragDown onDragLeft onSwipe onSwipeUp onSwipeRight onSwipeDown onSwipeLeft'.split(' '); GESTURE_DIRECTIVES.forEach(function(name) { IonicModule.directive(name, gestureDirective(name)); }); /** * @ngdoc directive * @name onHold * @module ionic * @restrict A * * @description * Touch stays at the same location for 500ms. Similar to long touch events available for AngularJS and jQuery. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onTap * @module ionic * @restrict A * * @description * Quick touch at a location. If the duration of the touch goes * longer than 250ms it is no longer a tap gesture. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onDoubleTap * @module ionic * @restrict A * * @description * Double tap touch at a location. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onTouch * @module ionic * @restrict A * * @description * Called immediately when the user first begins a touch. This * gesture does not wait for a touchend/mouseup. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onRelease * @module ionic * @restrict A * * @description * Called when the user ends a touch. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onDrag * @module ionic * @restrict A * * @description * Move with one touch around on the page. Blocking the scrolling when * moving left and right is a good practice. When all the drag events are * blocking you disable scrolling on that area. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onDragUp * @module ionic * @restrict A * * @description * Called when the element is dragged up. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onDragRight * @module ionic * @restrict A * * @description * Called when the element is dragged to the right. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onDragDown * @module ionic * @restrict A * * @description * Called when the element is dragged down. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onDragLeft * @module ionic * @restrict A * * @description * Called when the element is dragged to the left. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onSwipe * @module ionic * @restrict A * * @description * Called when a moving touch has a high velocity in any direction. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onSwipeUp * @module ionic * @restrict A * * @description * Called when a moving touch has a high velocity moving up. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onSwipeRight * @module ionic * @restrict A * * @description * Called when a moving touch has a high velocity moving to the right. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onSwipeDown * @module ionic * @restrict A * * @description * Called when a moving touch has a high velocity moving down. * * @usage * ```html * * ``` */ /** * @ngdoc directive * @name onSwipeLeft * @module ionic * @restrict A * * @description * Called when a moving touch has a high velocity moving to the left. * * @usage * ```html * * ``` */ function gestureDirective(directiveName) { return ['$ionicGesture', '$parse', function($ionicGesture, $parse) { var eventType = directiveName.substr(2).toLowerCase(); return function(scope, element, attr) { var fn = $parse( attr[directiveName] ); var listener = function(ev) { scope.$apply(function() { fn(scope, { $event: ev }); }); }; var gesture = $ionicGesture.on(eventType, listener, element); scope.$on('$destroy', function() { $ionicGesture.off(gesture, eventType, listener); }); }; }]; }